-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
51 lines (47 loc) · 910 Bytes
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import React, { Component } from 'react';
import {
Text,
View,
StyleSheet
} from 'react-native';
import Scanner from './Scanner';
import Results from './Results';
export default class App extends Component{
constructor(props) {
super(props);
this.state = {
qrcode: null,
scanArea: true
};
}
onRead = (qrcode) => {
this.setState({
qrcode,
scanArea: false
});
}
scanAgain = () => {
this.setState({
qrcode: null,
scanArea: true
});
}
render() {
const scanArea = this.state.scanArea ?
<Scanner onRead={this.onRead} /> :
<Results qrcode={this.state.qrcode} scanAgain={this.scanAgain} />;
return (
<View>
<View style={styles.container}>
{scanArea}
</View>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
flexDirection: 'row',
}
});