-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIdentifyMachine.js
94 lines (83 loc) · 2.14 KB
/
IdentifyMachine.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
import { StatusBar } from 'expo-status-bar';
import React, { Component } from 'react';
import { ActivityIndicator, FlatList, Text, View, StyleSheet, TouchableOpacity } from 'react-native';
import { MaterialCommunityIcons } from '@expo/vector-icons';
import * as Permissions from 'expo-permissions';
export default class IdentifyMachine extends Component {
constructor(props) {
super(props);
this.state = {
hasCameraPermission: null
};
const { navigation } = this.props;
this.navigation = navigation;
}
pressScan = () => {
this.getPermissionsAsync();
}
getPermissionsAsync = async () => {
const {
status
} = await Permissions.askAsync(Permissions.CAMERA);
this.setState({
hasCameraPermission: status === 'granted'
});
if (this.state.hasCameraPermission === null) {
} else if (this.state.hasCameraPermission === false) {
} else if (this.state.hasCameraPermission === true) {
this.navigation.navigate('QRscanner');
}
};
render() {
return (
<View style={styles.container}>
<View style={styles.viewBorder}>
<TouchableOpacity onPress={()=>this.pressScan()}>
<View style={styles.viewCenter}>
<MaterialCommunityIcons name="qrcode-scan" size={150} color="white" />
</View>
</TouchableOpacity>
</View>
<Text style={styles.text}>Tab to Scan QR</Text>
<StatusBar style='dark' />
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: 'white',
justifyContent: 'center',
alignItems: 'center'
},
viewCenter: {
height: 200,
width: 200,
backgroundColor: 'red',
justifyContent: 'center',
alignItems: 'center',
borderRadius: 25
},
viewBorder: {
height: 260,
width: 260,
borderWidth: 10,
borderColor: 'red',
justifyContent: 'center',
alignItems: 'center',
borderRadius: 50
},
viewBorder2: {
height: 400,
width: 290,
borderWidth: 1,
justifyContent: 'center',
alignItems: 'center'
},
text: {
fontSize: 40,
fontWeight: 'bold',
color: 'red'
}
});