Advertisement
Guest User

Parent.js

a guest
Oct 10th, 2019
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React from 'react';
  2. import {Button, View, Text} from 'react-native';
  3. import {createAppContainer} from 'react-navigation';
  4. import {createStackNavigator} from 'react-navigation-stack';
  5. import PageHeader from "../../PageHeader";
  6. import {Container, Content, Form, Input, Item, Label} from "native-base";
  7. import CaptureBarcode from "./CaptureBarcode";
  8. import CaptureImage from "./CaptureImage";
  9.  
  10.  
  11. class HomeScreen extends React.Component {
  12.  
  13.     constructor(props) {
  14.         super(props)
  15.         this.state = {
  16.             message: ""
  17.         }
  18.     }
  19.  
  20.     callbackFunction = (childData) => {
  21.         this.setState({message: childData})
  22.     }
  23.  
  24.     render() {
  25.         return (
  26.             <Container>
  27.                 <PageHeader navigation={this.props.navigation} title={'Create Item'}/>
  28.                 <Content>
  29.                     <Form>
  30.                         <Item stacked last>
  31.                             <Label>Name/Model</Label>
  32.                             <Input/>
  33.                         </Item>
  34.                         <Item stacked last>
  35.                             <Label>Brand</Label>
  36.                             <Input/>
  37.                         </Item>
  38.                         <Item disabled stacked last>
  39.                             <Label>Barcode</Label>
  40.                             <Input placeholder={this.state.message}/>
  41.                             <View style={{marginRight: 10}}>
  42.                                 <Button
  43.                                     style={{marginRight: 30}}
  44.                                     title="Scan"
  45.                                     onPress={() => {
  46.                                         this.props.navigation.navigate('Barcode', {
  47.                                             parentCallback: this.callbackFunction
  48.                                         })
  49.                                     }}
  50.                                 />
  51.                             </View>
  52.                         </Item>
  53.                         <Item stacked last>
  54.                             <View style={{marginRight: 10}}>
  55.                                 <Button
  56.                                     style={{marginRight: 30}}
  57.                                     title="Add Photo"
  58.                                     onPress={() => {
  59.                                         this.props.navigation.navigate('Camera')
  60.                                     }}
  61.                                 />
  62.                             </View>
  63.                         </Item>
  64.                         <Text>{this.state.message}</Text>
  65.                     </Form>
  66.                     <View>
  67.  
  68.                         <Button
  69.                             onPress={() => this.props.navigation.navigate('MyModal')}
  70.                             title="Info"
  71.                             color="#fff"
  72.                         />
  73.                         <Button
  74.                             onPress={() => this.props.navigation.navigate('MyModal2')}
  75.                             title="Info"
  76.                             color="#fff"
  77.                         />
  78.                     </View>
  79.                 </Content>
  80.             </Container>
  81.         )
  82.             ;
  83.     }
  84. }
  85.  
  86. const MainStack = createStackNavigator(
  87.     {
  88.         Home: {
  89.             screen: HomeScreen,
  90.         },
  91.     },
  92.     {
  93.         initialRouteName: 'Home',
  94.         defaultNavigationOptions: {
  95.             headerStyle: {
  96.                 backgroundColor: '#f4511e',
  97.             },
  98.             headerTintColor: '#fff',
  99.             headerTitleStyle: {
  100.                 fontWeight: 'bold',
  101.             },
  102.         },
  103.         headerMode: 'none'
  104.     }
  105. );
  106.  
  107. const RootStack = createStackNavigator(
  108.     {
  109.         Main: {
  110.             screen: MainStack,
  111.         },
  112.         Barcode: {
  113.             screen: CaptureBarcode,
  114.         },
  115.         Camera: {
  116.             screen: CaptureImage
  117.         },
  118.     },
  119.     {
  120.         mode: 'modal',
  121.         headerMode: 'none',
  122.     }
  123. );
  124.  
  125. const AppContainer = createAppContainer(RootStack);
  126.  
  127. export default AppContainer;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement