Navigatorbar cover content - react-native

I'm facing a problem that the navigatorbar covers all the contents
index.android.js
export default class RNTodosApp extends Component {
render() {
const routes = [
{title: 'Todos', index: 0}
];
return (
<Provider store={store}>
<View>
<StatusBar
backgroundColor='#0277BD'
barStyle='light-content'
/>
<Navigator
initialRoute={routes[0]}
initialRouteStack={routes}
navigationBar={
<Navigator.NavigationBar
routeMapper={{
LeftButton: (route, navigator, index, navState) =>
{ return; },
RightButton: (route, navigator, index, navState) =>
{ return; },
Title: (route, navigator, index, navState) => {
return (<Text style={styles.title}>{route.title}</Text>);
},
}}
style={styles.navigatorBar}
navigationStyles={Navigator.NavigationBar.StylesIOS}
/>
}
renderScene={(route, navigator) => {
if(route.index === 0) {
return (
<App />
)
}
}} />
</View>
</Provider>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#F5FCFF',
},
navigatorBar: {
backgroundColor: '#01579B',
},
title: {
color: '#FFFFFF',
fontSize: 20,
}
});
and the App.js file
class App extends Component {
render() {
console.log('Get called!');
return (
<View style={styles.container}>
<Text>Hello World!</Text>
<Text>Hello World!</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#000000'
}
})
Now the problem is I can't make the Hello World text to be displayed on the screen
Thank you.
I tried to add and change the alignItems and the justifyContent props but it's still doesn't work

I forgot the flex 1 in my code, solved!

Related

react native bar code reader is not working correctly?

Problem:
I have created a react native application. There I am using expo-barcode-scanner. This is how my code is organized.
import React, { Component } from "react";
import {
View,
Text,
StyleSheet,
TouchableOpacity,
Image,
TextInput,
ScrollView,
KeyboardAvoidingView,
} from "react-native";
import Dimensions from "Dimensions";
import * as Permissions from "expo-permissions";
import { BarCodeScanner } from "expo-barcode-scanner";
class Home extends Component {
constructor(props) {
super(props);
this.state = {
QrPress: false,
hasCameraPermission: null,
};
}
componentDidMount() {
this.getPermissionsAsync();
}
getPermissionsAsync = async () => {
const { status } = await Permissions.askAsync(Permissions.CAMERA);
this.setState({ hasCameraPermission: status === "granted" });
};
_onPress_QrScan() {
this.setState({
QrPress: true
});
}
handleBarCodeScanned = ({ type, data }) => {
this.setState({ QrPress: false, scanned: true, lastScannedUrl: data });
};
renderBarcodeReader() {
const { hasCameraPermission, scanned } = this.state;
if (hasCameraPermission === null) {
return <Text>Requesting for camera permission</Text>;
}
if (hasCameraPermission === false) {
return <Text>No access to camera</Text>;
}
return (
<View
style={{
flex: 1,
flexDirection: "column",
justifyContent: "flex-end"
}}
>
<BarCodeScanner
onBarCodeScanned={scanned ? undefined : this.handleBarCodeScanned}
style={StyleSheet.absoluteFillObject}
/>
{scanned && (
<Button
title={"Tap to Scan Again"}
onPress={() => this.setState({ scanned: false })}
/>
)}
</View>
);
}
render() {
const { hasCameraPermission, scanned, QrPress } = this.state;
let marker = null;
if (this.state.locationChosen) {
marker = <MapView.Marker coordinate={this.state.focusedLocation} />;
}
return (
<View style={{}}>
<KeyboardAvoidingView behavior="padding" enabled>
<ScrollView>
<TouchableOpacity
onPress={() => {
this._onPress_QrScan();
}}
activeOpacity={3}
>
<Text style={styles.viewDetails}>Scan QR</Text>
</TouchableOpacity>
{QrPress ? (
<React.Fragment>{this.renderBarcodeReader()}</React.Fragment>
) : (
null
)}
</ScrollView>
</KeyboardAvoidingView>
</View>
);
}
}
const DEVICE_WIDTH = Dimensions.get("window").width;
const DEVICE_HEIGHT = Dimensions.get("window").height;
const styles = StyleSheet.create({
container: {
top: 0,
flex: 3
},
map: {
flex: 1,
height: 130
},
homeHeader: {
flexDirection: "column",
flex: 1
},
homeHeaderImage: {
flexDirection: "row"
},
homeHederText: {
fontSize: 18,
fontWeight: "bold",
fontStyle: "normal",
fontFamily: "sans-serif",
letterSpacing: 0.81,
color: "#000104",
marginTop: "2%",
marginLeft: "40%",
marginRight: "3%"
},
hederContentContainer: {
flexDirection: "row",
marginTop: "30%",
marginBottom: "10%"
},
qrCodeGeneraterContainer: {
alignItems: "center",
justifyContent: "center"
},
});
export default Home;
But when I open the app with expo client on my android mobile. It is not rendering the barcode reader. It means It is not opening the camera to scan the QR. It just only shows a blank white background. I tried a lot to find out the solution to this problem. Unfortunately, I could not do anything with this issue. Can someone help me with this problem? Thank you.
There are a lot's of issue in your component. Please use the below code and update the style etc depend on your requirements.
import React, { Component } from "react";
import {
View,
Text,
StyleSheet,
TouchableOpacity,
Image,
TextInput,
ScrollView,
KeyboardAvoidingView,
Dimensions,
Button,
} from "react-native";
import MapView from 'react-native-maps';
import * as Permissions from "expo-permissions";
import { BarCodeScanner } from "expo-barcode-scanner";
class Home extends Component {
constructor(props) {
super(props);
this.state = {
QrPress: false,
hasCameraPermission: null,
};
}
componentDidMount() {
this.getPermissionsAsync();
}
getPermissionsAsync = async () => {
const { status } = await Permissions.askAsync(Permissions.CAMERA);
this.setState({ hasCameraPermission: status === "granted" });
};
_onPress_QrScan = () => {
this.setState({
QrPress: true
});
}
handleBarCodeScanned = ({ type, data }) => {
this.setState({ QrPress: false, scanned: true, lastScannedUrl: data });
};
renderBarcodeReader = () => {
const { hasCameraPermission, scanned } = this.state;
if (hasCameraPermission === null) {
return <Text>Requesting for camera permission</Text>;
}
if (hasCameraPermission === false) {
return <Text>No access to camera</Text>;
}
return (
<View
style={{
flex: 1,
flexDirection: "column",
justifyContent: "flex-end",
}}
>
<BarCodeScanner
onBarCodeScanned={scanned ? undefined : this.handleBarCodeScanned}
style={{ flex:1, ...StyleSheet.absoluteFillObject}}
/>
{scanned && (
<Button
title={"Tap to Scan Again"}
onPress={() => this.setState({ scanned: false })}
/>
)}
</View>
);
}
render() {
const { hasCameraPermission, scanned, QrPress } = this.state;
let marker = null;
if (this.state.locationChosen) {
marker = <MapView.Marker coordinate={this.state.focusedLocation} />;
}
return (
<View style={{flex:1}}>
<KeyboardAvoidingView behavior="padding" enabled style={{flex:1}}>
<ScrollView contentContainerStyle={{flexGrow: 1}} >
{QrPress ? (
<View style={{flex:1}}>
{this.renderBarcodeReader()}
</View>
) : (
<View style={{flex:1, justifyContent:'center', alignItems:'center'}}>
<TouchableOpacity
onPress={this._onPress_QrScan}
activeOpacity={3}
>
<Text style={styles.viewDetails}>Scan QR</Text>
</TouchableOpacity>
</View>
)}
</ScrollView>
</KeyboardAvoidingView>
</View>
);
}
}
const DEVICE_WIDTH = Dimensions.get("window").width;
const DEVICE_HEIGHT = Dimensions.get("window").height;
const styles = StyleSheet.create({
container: {
top: 0,
flex: 3
},
map: {
flex: 1,
height: 130
},
homeHeader: {
flexDirection: "column",
flex: 1
},
homeHeaderImage: {
flexDirection: "row"
},
homeHederText: {
fontSize: 18,
fontWeight: "bold",
fontStyle: "normal",
fontFamily: "sans-serif",
letterSpacing: 0.81,
color: "#000104",
marginTop: "2%",
marginLeft: "40%",
marginRight: "3%"
},
hederContentContainer: {
flexDirection: "row",
marginTop: "30%",
marginBottom: "10%"
},
qrCodeGeneraterContainer: {
alignItems: "center",
justifyContent: "center"
},
});
export default Home;

How to display both Bottom Navigator and Drawer Navigator in React Native

I am new to React Native. I want to build Bottom Navigator and Drawer Navigation. I used the below code, I am unable to navigate to the page from Drawer Menu. I am able to navigate to the page from Tab Navigator.
In the code both Drawer Navigator and Tab Navigator Screens are different.
import React, { Component } from "react";
import { StyleSheet, Text, View, TouchableOpacity } from "react-native";
import Icon from "#expo/vector-icons/Ionicons";
import {
createAppContainer,
createDrawerNavigator,
createBottomTabNavigator,
createStackNavigator
} from "react-navigation";
import { Constants } from "expo";
const DrawerMenuItems = [
{
title: "Login",
icon: "ios-home",
navigateTo: "Login"
},
{
title: "Feedback",
icon: "ios-home",
navigateTo: "Feedback"
},
{
title: "Help",
icon: "ios-help",
navigateTo: "Help"
}
];
export default class App extends React.Component {
render() {
return <AppContainer />;
}
}
class HomeScreen extends Component {
render() {
return (
<View style={styles.container}>
<Text>HomeScreen</Text>
</View>
);
}
}
class ContactScreen extends Component {
render() {
return (
<View style={styles.container}>
<Text>ContactScreen</Text>
</View>
);
}
}
class AboutScreen extends Component {
render() {
return (
<View style={styles.container}>
<Text>AboutScreen</Text>
</View>
);
}
}
class LoginScreen extends Component {
render() {
return (
<View style={styles.container}>
<Text>LoginScreen</Text>
</View>
);
}
}
class FeedbackScreen extends Component {
render() {
return (
<View style={styles.container}>
<Text>FeedbackScreen</Text>
</View>
);
}
}
class HelpScreen extends Component {
render() {
return (
<View style={styles.container}>
<Text>HelpScreen</Text>
</View>
);
}
}
class HamburgerMenu extends Component {
constructor(props) {
super(props);
}
renderMenu(menuItems) {
{
return menuItems.map((item, index) => {
return (
<View style={{ width: "100%" }} key={index}>
<View style={styles.sideMenuItem}>
<TouchableOpacity
style={styles.sideMenuIcon}
onPress={() => {
this.props.navigation.navigate(item.navigateTo);
}}
>
<Icon name={item.icon} size={30} />
</TouchableOpacity>
<Text
style={styles.menuText}
onPress={() => {
this.props.navigation.navigate(item.navigateTo);
}}
>
{item.title}
</Text>
</View>
</View>
);
});
}
}
render() {
return (
<View style={styles.sideMenuContainer}>
{this.renderMenu(DrawerMenuItems)}
</View>
);
}
}
const DrawerButton = ({ navigation }) => (
<TouchableOpacity onPress={() => navigation.openDrawer()}>
<Icon style={styles.menuIcon} name="md-menu" size={30} />
</TouchableOpacity>
);
const BottomTabsNavigator = createBottomTabNavigator(
{
Home: HomeScreen,
Contact: ContactScreen,
About: AboutScreen
},
{
tabBarOptions: {
activeTintColor: "#000",
inactiveTintColor: "gray",
style: {
backgroundColor: "#fff"
},
indicatorStyle: {
backgroundColor: "#000"
}
}
}
);
const AppDrawNavigator = createDrawerNavigator(
{
Main: { screen: BottomTabsNavigator }
},
{
contentComponent: HamburgerMenu,
drawerPosition: "right"
}
);
const AppStackNavigator = createStackNavigator(
{
MainDrawNavigator: {
screen: AppDrawNavigator
}
},
{
defaultNavigationOptions: ({ navigation }) => {
return {
header: (
<View style={styles.header}>
<DrawerButton navigation={navigation} />
</View>
),
headerStyle: {
height: 60
}
};
}
}
);
const AppContainer = createAppContainer(AppStackNavigator);
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
alignItems: "center",
justifyContent: "center"
},
sideMenuContainer: {
width: "100%",
height: "100%",
backgroundColor: "#fff",
alignItems: "center",
paddingTop: 20
},
sideMenuProfileIcon: {
resizeMode: "center",
width: 150,
height: 150,
borderRadius: 150 / 2
},
sideMenuIcon: {
resizeMode: "center",
width: 28,
height: 28,
marginRight: 10,
marginLeft: 20
},
menuIcon: {
left: 10
},
menuText: {
fontSize: 15,
color: "#222222"
},
header: {
paddingTop: Constants.statusBarHeight,
backgroundColor: "#e1e8ee",
flexDirection: "row"
}
});
Kindly help on this.

React Native: Navigation not working in component

I can not open the third page screen with the On Press method in the List Component.js file. I do not understand the problem. I want to know what I'm doing wrong with this. Where is the problem? Thank you. Please help.
Thank you for your reply but this will not work, my friend. I've updated the ListComponent.js file. The ListComponent.js file is actually a list. Please can you look again. ?
App.js
import React, { Component } from 'react';
import {
WebView,
AppRegistry, StyleSheet, Text, View, Button
} from 'react-native';
import { StackNavigator } from 'react-navigation';
import ListComponent from './ListComponent';
class App extends Component {
static navigationOptions =
{
title: 'App',
};
OpenSecondActivityFunction = () =>
{
this.props.navigation.navigate('Second');
}
render() {
return (
<View style={styles.container}>
<Button onPress = { this.OpenSecondActivityFunction } title = 'Open Second Activity'/>
</View>
);
}
}
class SecondActivity extends Component
{
static navigationOptions =
{
title: 'SecondActivity',
};
OpenThirdActivityFunction = () =>
{
this.props.navigation.navigate('Third');
}
render()
{
return(
<View style={{ flex: 1}}>
<ListComponents data={alapinCtrl} OpenThirdActivityFunction={this.OpenThirdActivityFunction} />
</View>
);
}
}
class ThirdActivity extends Component
{
static navigationOptions =
{
title: 'ThirdSecondActivity',
};
render()
{
return(
<View style={{ flex: 1}}>
<Text>3</Text>
</View>
);
}
}
export default ActivityProject = StackNavigator(
{
First: { screen: App },
Second: { screen: SecondActivity },
Third: { screen: ThirdActivity }
});
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},ActivityNameTextCss:
{
fontSize: 22,
color: 'black',
textAlign: 'center',
},
});
AppRegistry.registerComponent('ActivityProject', () => ActivityProject);
ListComponent.js
import React, { Component } from "react";
import {AppRegistry,View, Text, FlatList, ActivityIndicator} from "react-native";
import { List, ListItem, SearchBar } from "react-native-elements";
class ListComponents extends Component {
constructor(props) {
super(props);
this.state = {
loading: false,
data: [],
page: 1,
seed: 1,
error: null,
refreshing: false
};
}
renderSeparator = () => {
return (
<View
style={{
height: 1,
width: "98%",
backgroundColor: "#CED0CE",
marginLeft: "2%"
}}
/>
);
};
renderHeader = () => {
return <SearchBar placeholder="Type Here..." lightTheme round />;
};
renderFooter = () => {
if (!this.state.loading) return null;
return (
<View
style={{
paddingVertical: 20,
borderTopWidth: 1,
borderColor: "#CED0CE"
}}
>
<ActivityIndicator animating size="large" />
</View>
);
};
render() {
return (
<List containerStyle={{ borderTopWidth: 0, borderBottomWidth: 0 }}>
<FlatList
data={this.props.data}
renderItem={({ item }) => (
<ListItem
roundAvatar
title={`${item.name}`}
subtitle={item.coders}
containerStyle={{ borderBottomWidth: 0 }}
onPress={() => this.props.OpenThirdActivityFunction(item.coders)}
/>
)}
keyExtractor={item => item.coders}
ItemSeparatorComponent={this.renderSeparator}
ListHeaderComponent={this.renderHeader}
ListFooterComponent={this.renderFooter}
/>
</List>
);
}
}
export default ListComponents;
Only SecondActivity has the navigation prop; you need to explicitly pass it to child component:
<ListComponent navigation={this.props.navigation} />
Alternatively,
<ListComponent onPress={() => this.props.navigation.navigate('Third')} />;
Then just do <Button onPress={this.props.onPress} in your ListComponent.

Select a row in ListView react-native to get detail

i'm new in react-native. I saw an example in https://facebook.github.io/react-native/docs/sample-application-movies.html .
It is building a movies app that fetch movies and display them in a ListView. How can we select a row to get its detail data and display it in other view? Please help. thanks :)
Here's what i've done so far:
/**
* Sample React Native App
* https://github.com/facebook/react-native
*/
import React, {
Component,
} from 'react';
import {
AppRegistry,
Image,
ListView,
StyleSheet,
Text,
View,
Navigator,
TouchableOpacity,
} from 'react-native';
var REQUEST_URL = 'https://raw.githubusercontent.com/facebook/react-native/master/docs/MoviesExample.json';
var SCREEN_WIDTH = require('Dimensions').get('window').width;
var BaseConfig = Navigator.SceneConfigs.FloatFromRight;
var CustomLeftToRightGesture = Object.assign({}, BaseConfig.gestures.pop, {
snapVelocity: 8,
edgeHitWidth: SCREEN_WIDTH,
});
var CustomSceneConfig = Object.assign({}, BaseConfig, {
springTension: 100,
springFriction: 1,
gestures: {
pop: CustomLeftToRightGesture,
}
});
var PageOne = React.createClass({
getInitialState:function(){
return{
dataSource: new ListView.DataSource({
rowHasChanged: (row1, row2) => row1 !== row2,
}),
loaded: false,
}
},
componentDidMount() {
this.fetchData();
},
fetchData() {
fetch(REQUEST_URL)
.then((response) => response.json())
.then((responseData) => {
this.setState({
dataSource: this.state.dataSource.cloneWithRows(responseData.movies),
loaded: true,
});
})
.done();
},
render() {
if (!this.state.loaded) {
return this.renderLoadingView();
}
return (
<ListView
dataSource={this.state.dataSource}
renderRow={this.renderMovie}
style={styles.listView}
/>
);
},
renderLoadingView() {
return (
<View style={styles.container}>
<Text>
Loading movies...
</Text>
</View>
);
},
renderMovie(movie) {
title1 = movie.title;
year1 = movie.year;
return (
<TouchableOpacity onPress={this._handlePressList}>
<View style={styles.container}>
<Image
source={{uri: movie.posters.thumbnail}}
style={styles.thumbnail}
/>
<View style={styles.rightContainer}>
<Text style={styles.title}>{movie.title}</Text>
<Text style={styles.year}>{movie.year}</Text>
</View>
</View>
</TouchableOpacity>
);
},
_handlePressList(){
this.props.navigator.push({id: 2, title1, year1});
},
});
var PageTwo = React.createClass({
render(){
return(
<View style={styles.rightContainer}>
<Text style={styles.title}>{title1}</Text>
<Text style={styles.year}>{year1}</Text>
</View>
)
}
})
class SampleAppMovies extends Component{
_renderScene(route, navigator) {
if (route.id === 1) {
return <PageOne navigator={navigator} />
} else if (route.id === 2) {
return <PageTwo navigator={navigator} />
}
}
_configureScene(route) {
return CustomSceneConfig;
}
render() {
return (
<Navigator
initialRoute={{id: 1, }}
renderScene={this._renderScene}
configureScene={this._configureScene} />
);
}
}
var styles = StyleSheet.create({
container: {
flex: 1,
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
rightContainer: {
flex: 1,
},
title: {
fontSize: 20,
marginBottom: 8,
textAlign: 'center',
},
year: {
textAlign: 'center',
},
thumbnail: {
width: 53,
height: 81,
},
listView: {
paddingTop: 20,
backgroundColor: '#F5FCFF',
},
});
module.exports = SampleAppMovies;
In your renderRow method (in your case renderMovie), simply pass the movie in onPress prop of TouchableOpacity, something like this:
renderMovie(movie) {
title1 = movie.title;
year1 = movie.year;
return (
<TouchableOpacity onPress={() => _handlePressList(movie)}> // SEE HERE!!
<View style={styles.container}>
<Image
source={{uri: movie.posters.thumbnail}}
style={styles.thumbnail}
/>
<View style={styles.rightContainer}>
<Text style={styles.title}>{movie.title}</Text>
<Text style={styles.year}>{movie.year}</Text>
</View>
</View>
</TouchableOpacity>
);
},
_handlePressList(movie){
this.props.navigator.push({id: 2, movie.title1, movie.year1});
},
Then you can do whatever you want with the movie.
Hope it's helpful.
renderMovie(movie) {
title1 = movie.title;
year1 = movie.year;
return (
<TouchableOpacity onPress={this._handlePressList.bind(this, movie)}
<View style={styles.container}>
<Image
source={{uri: movie.posters.thumbnail}}
style={styles.thumbnail}
/>
<View style={styles.rightContainer}>
<Text style={styles.title}>{movie.title}</Text>
<Text style={styles.year}>{movie.year}</Text>
</View>
</View>
</TouchableOpacity>
);
},
_handlePressList(movie){
this.props.navigator.push({id: 2, movie.title1, movie.year1});
},
This will solve the problem

Navigator with args

I created an Android app with Navigator.
On my first page, I want to push differents informations to the next page if I push with a button or with an other.
I created gotoNext function as below. But, I don't understand how I can replace my typedmg: 'test' by an argument which represent the button Pole or Aerial.
Thanks for your help.
class LoginPage extends React.Component {
render() {
return (
<Navigator
renderScene={this.renderScene.bind(this)}
navigator={this.props.navigator}
navigationBar={
<Navigator.NavigationBar routeMapper= NavigationBarRouteMapper} />
} />
);
}
renderScene(route, navigator) {
return (
....
<View style={{flex: 4, flexDirection: 'column'}}>
<TouchableHighlight name='Pole' onPress={this.gotoNext}>
<Image source={require('./img/radio_damage_pole.png')} />
</TouchableHighlight>
<TouchableHighlight name='Aerial' onPress={this.gotoNext}>
<Image source={require('./img/radio_damage_aerial.png')} />
</TouchableHighlight>
</View>
...
);
}
gotoNext() {
this.props.navigator.push({
id: 'page_user_infos',
name: 'page_user_infos',
typedmg: 'test',
});
}
}
You need to set up your Navigator to pass properties by assigning the passProps spread operator to the Navigator. The best way to do that is to separate your navigator into it's own component, then assign properties to it.
I've taken your project and set up a similar functioning one here. There was another similar thread you may be able to reference here as well. Below is the code I used to get it working, I hope this helps!
https://rnplay.org/apps/UeyIBQ
'use strict';
var React = require('react-native');
var {
AppRegistry,
StyleSheet,
Text,
View,
Navigator,
Image,
TouchableHighlight, TouchableOpacity
} = React;
class Two extends React.Component {
render(){
return(
<View style={{marginTop:100}}>
<Text style={{fontSize:20}}>Hello From second component</Text>
<Text>id: {this.props.id}</Text>
<Text>name: {this.props.name}</Text>
<Text>name: {this.props.typedmg}</Text>
</View>
)
}
}
class Main extends React.Component {
gotoNext(myVar) {
this.props.navigator.push({
component: Two,
passProps: {
id: 'page_user_infos',
name: 'page_user_infos',
typedmg: myVar,
}
})
}
render() {
return(
<View style={{flex: 4, flexDirection: 'column', marginTop:40}}>
<TouchableHighlight style={{height:40, borderWidth:1, marginBottom:10}} name='Pole' onPress={ () => this.gotoNext('Pole') }>
<Text>Pole</Text>
</TouchableHighlight>
<TouchableHighlight style={{height:40, borderWidth:1, marginBottom:10}} name='Aerial' onPress={ () => this.gotoNext('Aerial') }>
<Text>Aerial</Text>
</TouchableHighlight>
</View>)
}
}
class App extends React.Component {
render() {
return (
<Navigator
initialRoute={{name: 'Main', component: Main, index: 0}}
renderScene={(route, navigator) => {
if (route.component) {
return React.createElement(route.component, { ...this.props, ...route.passProps, navigator, route } );
}
}}
navigationBar={
<Navigator.NavigationBar routeMapper={NavigationBarRouteMapper} />
} />
);
}
}
var NavigationBarRouteMapper = {
LeftButton(route, navigator, index, navState) {
if(index > 0) {
return (
<TouchableHighlight style={{marginTop: 10}} onPress={() => {
if (index > 0) {
navigator.pop();
}
}}>
<Text>Back</Text>
</TouchableHighlight>
)} else {
return null}
},
RightButton(route, navigator, index, navState) {
return null;
},
Title(route, navigator, index, navState) {
return (
<TouchableOpacity style={{flex: 1, justifyContent: 'center'}}>
<Text style={{color: 'white', margin: 10, fontSize: 16}}>
Data Entry
</Text>
</TouchableOpacity>
);
}
};
var styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 28,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
fontSize: 19,
marginBottom: 5,
},
});
AppRegistry.registerComponent('App', () => App);