How to limit BarCodeScanner zone

Hi,
Is it possible to make BarCodeScanner to focus only on the QR inside the white rectangle and ignore all the rest ?

Thanks in advance

1 Like

you can use 'react-native-barcode-mas’

example

import BarcodeMask from 'react-native-barcode-mask';
<BarCodeScanner onBarCodeScanned={handleBarCodeScanned} ...>
...
<BarcodeMask edgeColor="#62B1F6" showAnimatedLine/>
</BarCodeScanner>

remember

const finderWidth = 280;
const finderHeight = 630;
const width = Dimensions.get('window').width;
const height = Dimensions.get('window').height;
const viewMinX = (width - finderWidth) / 2;
const viewMinY = (height - finderHeight) / 2;

const handleBarCodeScanned = ({ type, data, bounds: { origin } = {}}) => {
if (x >= viewMinX && y >= viewMinY && x <= (viewMinX + finderWidth / 2) && y <= (viewMinY + finderHeight / 2)) {
       setScanned(true);
       ...
}