This repository was archived by the owner on Aug 25, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ios.js
69 lines (61 loc) · 1.43 KB
/
index.ios.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
import PropTypes from 'prop-types';
import React, {Component} from 'react';
import {
NativeModules,
requireNativeComponent,
StyleSheet,
SafeAreaView,
ViewPropTypes
} from 'react-native';
let RNScanView = requireNativeComponent('RNScanView', ScanView);
let {
Camera,
Flash,
Barcode
} = NativeModules.RNScanViewManager;
class ScanView extends Component {
static Const = {
'Camera': Camera,
'Flash': Flash,
'Barcode': Barcode
};
static propTypes = {
...ViewPropTypes,
onScanCode: PropTypes.func.isRequired,
codeTypes: PropTypes.array,
camera: PropTypes.number,
flash: PropTypes.number
};
_onScanCode = (event) => {
if (!this.props.onScanCode) {
return
}
this.props.onScanCode(event.nativeEvent);
};
static defaultProps = {
codeTypes: Object.values(Barcode),
camera: Camera.back,
flash: Flash.off
};
render() {
return (
<SafeAreaView style={styles.container}>
<RNScanView
{...this.props}
onScanCode={this._onScanCode}
style={styles.scanView}
/>
</SafeAreaView>
)
}
}
styles = StyleSheet.create({
container: {
flex: 1
},
scanView: {
flex: 1,
alignSelf: 'stretch'
}
});
export default ScanView;