-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBarcodeReaderView.js
47 lines (41 loc) · 955 Bytes
/
BarcodeReaderView.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
'use strict';
import React, {
PropTypes,
Component,
View,
requireNativeComponent,
} from 'react-native';
export default class BarcodeReaderView extends Component {
static propTypes = {
...View.propTypes,
onBarCodeRead: PropTypes.func,
rotation: PropTypes.number,
scaleX: PropTypes.number,
scaleY: PropTypes.number,
translateX: PropTypes.number,
translateY: PropTypes.number,
}
constructor(props) {
super(props);
this.onChange = this.onChange.bind(this);
}
onChange(event) {
if (!this.props.onBarCodeRead) {
return;
}
this.props.onBarCodeRead({
type: event.nativeEvent.type,
data: event.nativeEvent.data,
});
}
render() {
return (
<RCTBarcodeReaderView {...this.props} onChange={this.onChange} />
);
}
}
let RCTBarcodeReaderView = requireNativeComponent('RCTBarcodeReaderView', BarcodeReaderView, {
nativeOnly: {
onChange: true
}
});