...
|
...
|
@@ -14,20 +14,24 @@ import ReactNative, { |
|
|
NetInfo,
|
|
|
} from 'react-native';
|
|
|
|
|
|
import Camera from 'react-native-camera';
|
|
|
import Camera from 'yh_rncamera';
|
|
|
const yh_QRCodeHelperEvt = new NativeEventEmitter(ReactNative.NativeModules.YH_QRCodeHelper)
|
|
|
|
|
|
let camera;
|
|
|
let scanTypeValue, animationFromTopToBottom;
|
|
|
let animationStartHeight = Dimensions.get('window').height * 0.10;
|
|
|
let animationEndHeight = Dimensions.get('window').height * 0.44;
|
|
|
let kScreenPointScale = Dimensions.get('window').width/320.0;
|
|
|
let kScreenPoint6Scale = Dimensions.get('window').width/375.0;
|
|
|
let KScanRectOfInterestWidth = (175+220)*kScreenPointScale/Dimensions.get('window').height;
|
|
|
let KScanRectOfInterestHeight = (190+220)*kScreenPointScale/ Dimensions.get('window').width;
|
|
|
|
|
|
export default class QRCode extends React.Component {
|
|
|
|
|
|
startAnimation() {
|
|
|
Animated.timing(this.state.destX, {
|
|
|
toValue: animationFromTopToBottom ? animationEndHeight : animationStartHeight,
|
|
|
duration: 2500,
|
|
|
duration: 1500,
|
|
|
}).start(() => {
|
|
|
this.startAnimation();
|
|
|
animationFromTopToBottom = !animationFromTopToBottom;
|
...
|
...
|
@@ -49,17 +53,6 @@ export default class QRCode extends React.Component { |
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_onBarCodeRead(e) {
|
|
|
console.log(e);
|
|
|
let type = scanTypeValue;
|
|
|
if (e.bounds.origin.x >= 50 && e.bounds.origin.x <= 250 && e.bounds.origin.y >= 70 && e.bounds.origin.y < 270 && e.bounds.size.width < 200 && e.bounds.size.height < 200) {
|
|
|
camera._removeOnBarCodeReadListener();
|
|
|
this.props._onBarCodeRead && this.props._onBarCodeRead(e.data);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
render() {
|
|
|
let {scanType} = this.props;
|
|
|
scanTypeValue = scanType;
|
...
|
...
|
@@ -77,6 +70,7 @@ export default class QRCode extends React.Component { |
|
|
this.props.onBarCodeRead && this.props.onBarCodeRead(e.data);
|
|
|
}
|
|
|
}}
|
|
|
rectOfCameraInterest={{x:0, y:0, width:KScanRectOfInterestWidth, height:KScanRectOfInterestHeight}}//{{x:0, y:0, width:0.69542253, height:1.28125 }}
|
|
|
style={styles.camera}
|
|
|
captureAudio={false}
|
|
|
>
|
...
|
...
|
|