Created
November 1, 2020 18:58
-
-
Save medic-code/f95004863480bc6552fab53c8fe7fc6e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import QRCodeScanner from 'react-native-qrcode-scanner'; | |
import RNCamera from 'react-native-camera'; | |
import { | |
TouchableOpacity, | |
View, | |
Text, | |
} from 'react-native'; | |
import WebView from 'react-native-webview' | |
export default class App extends Component { | |
state = { | |
webview: false, | |
url: '' | |
} | |
onSuccess = e => { | |
this.setState({url: e.data, webview: true}) | |
}; | |
render() { | |
return ( | |
<View style={{flex:1}}> | |
<View style={{flex:1}}> | |
{this.state.webview && (<WebView | |
source={{uri: this.state.url}} | |
style={{flex:1}} | |
scalesPageToFit={true} /> | |
)} | |
{!this.state.webview && (<QRCodeScanner | |
onRead={this.onSuccess.bind(this)} | |
reactivate={true} | |
reactivateTimeout={4000}/> | |
)} | |
<TouchableOpacity | |
style={{ | |
alignItems: 'center', | |
justifyContent: 'center', | |
backgroundColor: 'rgba(0,0,0,0.2)', | |
borderRadius: 50, | |
width: 75, | |
height: 75, | |
position: 'absolute', | |
right: 5, | |
bottom: 5 | |
}} | |
onPress={() => this.setState({ webview: false })} | |
> | |
<Text style={{textAlign: 'center'}}>Click to Reload</Text> | |
</TouchableOpacity> | |
</View> | |
</View> | |
); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment