-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsample.js
39 lines (32 loc) · 1012 Bytes
/
sample.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
import React, { Component } from 'react';
import { AppRegistry, StyleSheet, Text, View, TouchableOpacity, Image } from 'react-native';
import Scanbot from 'react-native-scanbot';
const styles = StyleSheet.create({
viewport: {
flex: 1,
justifyContent: 'center',
backgroundColor: '#F5FCFF',
},
});
Scanbot.setLicense('');
export default class example extends Component {
state = {
image: '',
}
onPress = async () => {
const image = await Scanbot.scan({});
this.setState({ image: `data:image/jpeg;base64,${image}` });
}
render() {
const { image } = this.state;
return (
<View style={styles.viewport}>
<Image style={{ flex: 1 }} source={{ uri: image }} />
<TouchableOpacity style={{ padding: 10, margin: 5, alignItems: 'center', borderWidth: StyleSheet.hairlineWidth }} onPress={this.onPress}>
<Text>Open Scanbot</Text>
</TouchableOpacity>
</View>
);
}
}
AppRegistry.registerComponent('example', () => example);