-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqrcode.js
More file actions
80 lines (68 loc) · 2.01 KB
/
qrcode.js
File metadata and controls
80 lines (68 loc) · 2.01 KB
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
'use strict';
import React, { Component } from 'react';
import { Text, Linking,View,ToastAndroid, TouchableOpacity} from 'react-native';
import { withNavigation } from 'react-navigation';
import {Icon} from 'react-native-elements'
import QRCodeScanner from 'react-native-qrcode-scanner';
class ScanScreen extends Component {
state = {
data:""
}
static navigationOptions = ({navigation}) => ({
headerStyle: {
backgroundColor: '#2B56BE',
elevation: 0,
},
headerTintColor: '#000',
headerTitleStyle: {
fontWeight: 'bold',
alignItems: 'center',
fontSize: 22,
},
headerTitle: (
<Text style={{color:'#fff',fontSize:26}}> Scan QR Code</Text>
),
headerLeft: (
<View style={{ paddingLeft: 19 }}>
<TouchableOpacity onPress={() => navigation.goBack()}><Icon type="font-awesome" name="arrow-left" color={'#fff'}></Icon></TouchableOpacity>
</View>
),
});
onSuccess = (e) => {
var abc = this.props.navigation.getParam('pid', "hello123")
this.setState({data:e.data})
fetch('http://5e9ef292.ngrok.io', {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({"uid":"hello123"})
})
//.then((response) => response.json())
//.then((responseJson) => {
//this.setState({data:responseJson})})
//.catch((error) => {
//console.error(error);
//});
ToastAndroid.show(abc, ToastAndroid.SHORT);
ToastAndroid.show(e.data, ToastAndroid.SHORT);
this.props.navigation.goBack()
Linking
.openURL(e.data)
.catch((err)=>{
console.log("An error occured",err)
})
}
render() {
return (
<View>
<Text style={{fontFamily:'Roboto',fontSize:16}}>{'\n'} Focus in on the doctor's referral QR Code{'\n\n\n\n'}</Text>
<QRCodeScanner
onRead={this.onSuccess}
/>
</View>
);
}
}
export default withNavigation(ScanScreen)