-
Notifications
You must be signed in to change notification settings - Fork 4
/
App.js
103 lines (96 loc) · 2.31 KB
/
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import React, { useState } from 'react';
import { StyleSheet, Text, View, TouchableOpacity, SafeAreaView } from 'react-native';
import { RNCamera } from 'react-native-camera';
function App() {
const [barcode, setBarcode] = useState(null);
return (
<View style={styles.screen}>
<SafeAreaView style={styles.saveArea}>
<View style={styles.topBar}>
<Text style={styles.topBarTitleText}>React Native Scanner</Text>
</View>
</SafeAreaView>
<View style={styles.caption}>
<Text style={styles.captionTitleText}>Welcome To React-Native-Camera Tutorial</Text>
</View>
{barcode ? (
<View style={[styles.rnCamera, styles.rmCameraResult]}>
<Text style={styles.rmCameraResultText}>{barcode.data}</Text>
<Text style={styles.rmCameraResultText}>{barcode.type}</Text>
</View>
) : (
<RNCamera
style={styles.rnCamera}
onBarCodeRead={setBarcode}
/>
)}
<View style={styles.cameraControl}>
<TouchableOpacity style={styles.btn} onPress={() => setBarcode(null)}>
<Text style={styles.btnText}>New QR Scan</Text>
</TouchableOpacity>
</View>
</View>
);
};
const styles = StyleSheet.create({
screen: {
flex: 1,
backgroundColor: '#F2F2FC',
},
saveArea: {
backgroundColor: '#62d1bc',
},
topBar: {
height: 50,
backgroundColor: '#62d1bc',
alignItems: 'center',
justifyContent: 'center',
},
topBarTitleText: {
color: '#ffffff',
fontSize: 20,
},
caption: {
height: 120,
justifyContent: 'center',
alignItems: 'center',
},
captionTitleText: {
color: '#121B0D',
fontSize: 16,
fontWeight: '600'
},
btn: {
width: 240,
borderRadius: 4,
backgroundColor: '#62d1bc',
paddingHorizontal: 24,
paddingVertical: 12,
marginVertical: 8,
},
btnText: {
fontSize: 18,
color: '#ffffff',
textAlign: 'center',
},
rnCamera: {
flex: 1,
width: '94%',
alignSelf: 'center',
},
rmCameraResult: {
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#eeeeee',
},
rmCameraResultText: {
fontSize: 20,
color: '#62d1bc'
},
cameraControl: {
height: 180,
justifyContent: 'center',
alignItems: 'center',
}
});
export default App;