add ExampleScreen for checking correct work of scanner

This commit is contained in:
Dmytro Ponomarenko 2018-03-12 10:30:06 +02:00
parent bacebf8d31
commit 33adc9f0d6
2 changed files with 67 additions and 1 deletions

View File

@ -3,10 +3,17 @@ import {
Alert
} from 'react-native';
import { CameraKitCameraScreen } from 'react-native-camera-kit';
import ExampleScreen from './ExampleScreen';
export default class CameraScreen extends Component {
constructor(props) {
super(props);
this.state = {
example: undefined
};
}
onBottomButtonPressed(event) {
const captureImages = JSON.stringify(event.captureImages);
@ -21,6 +28,10 @@ export default class CameraScreen extends Component {
}
render() {
if (this.state.example) {
const CameraScreen = this.state.example;
return <CameraScreen />;
}
return (
<CameraKitCameraScreen
actions={{ rightButtonText: 'Done', leftButtonText: 'Cancel' }}
@ -35,7 +46,8 @@ export default class CameraScreen extends Component {
laserColor={"blue"}
frameColor={"yellow"}
onReadCode={((event) => Alert.alert(`Qr code found ${event.nativeEvent.codeStringValue} `))}
//onReadCode={((event) => Alert.alert(`Qr code found ${event.nativeEvent.codeStringValue} `))}
onReadCode = {((event) => this.setState({ example: ExampleScreen}))}
hideControls={true}
isNeedMultipleScanBarcode = {true}
// offsetForScannerFrame = {10}

View File

@ -0,0 +1,54 @@
import React, { Component } from 'react';
import {
Alert,
View,
TouchableOpacity,
Text,
StyleSheet
} from 'react-native';
import BarcodeScreen from './BarcodeScreen';
export default class ExampleScreen extends Component {
constructor(props) {
super(props);
this.state = {
example: undefined
};
}
render() {
if (this.state.example) {
const ExampleScreen = this.state.example;
return <ExampleScreen />;
}
return (
<View style = {styles.container}>
<TouchableOpacity onPress={(() => this.setState({example : BarcodeScreen}))}>
<Text style={styles.buttonText}>
Back button
</Text>
</TouchableOpacity>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
// justifyContent: 'center',
paddingTop: 60,
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
buttonText: {
color: 'blue',
marginBottom: 20,
fontSize: 20
}
});