SHARE
TWEET

Untitled

a guest Sep 17th, 2019 95 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* eslint-disable react/jsx-props-no-spreading */
  2. import React from 'react';
  3. import PropTypes from 'prop-types';
  4. import { RNCamera } from 'react-native-camera';
  5.  
  6. const RNCameraAndroid = ({ callback, children, ...props }) => {
  7.   const barcodeHandler = ({ barcodes }) => {
  8.     if (barcodes.length === 0) {
  9.       return;
  10.     }
  11.     callback(barcodes[0].data);
  12.   };
  13.  
  14.   return (
  15.     <RNCamera
  16.       // By default the RNCamera uses the old code detection on Android when using onBarCodeRead,
  17.       // therefore we need to configure it to use MLKit to get better performance.
  18.       onGoogleVisionBarcodesDetected={barcodeHandler}
  19.       googleVisionBarcodeType={RNCamera.Constants.GoogleVisionBarcodeDetection.BarcodeType.QR_CODE}
  20.       {...props}>
  21.       {children}
  22.     </RNCamera>
  23.   );
  24. };
  25.  
  26. RNCameraAndroid.propTypes = {
  27.   callback: PropTypes.func.isRequired,
  28.   children: PropTypes.node,
  29. };
  30.  
  31. RNCameraAndroid.defaultProps = {
  32.   children: null,
  33. };
  34.  
  35. export default RNCameraAndroid;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top