Fix qr code scanner not working
This commit is contained in:
parent
6e7b3d02cd
commit
25a12dad94
1 changed files with 6 additions and 7 deletions
|
@ -20,7 +20,7 @@
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import {Linking, Platform, StyleSheet, View} from 'react-native';
|
import {Linking, Platform, StyleSheet, View} from 'react-native';
|
||||||
import {Button, Text} from 'react-native-paper';
|
import {Button, Text} from 'react-native-paper';
|
||||||
import {RNCamera} from 'react-native-camera';
|
import {BarCodeReadEvent, RNCamera} from 'react-native-camera';
|
||||||
import {BarcodeMask} from '@nartc/react-native-barcode-mask';
|
import {BarcodeMask} from '@nartc/react-native-barcode-mask';
|
||||||
import i18n from 'i18n-js';
|
import i18n from 'i18n-js';
|
||||||
import {PERMISSIONS, request, RESULTS} from 'react-native-permissions';
|
import {PERMISSIONS, request, RESULTS} from 'react-native-permissions';
|
||||||
|
@ -107,7 +107,7 @@ class ScannerScreen extends React.Component<{}, StateType> {
|
||||||
<RNCamera
|
<RNCamera
|
||||||
onBarCodeRead={state.scanned ? undefined : this.onCodeScanned}
|
onBarCodeRead={state.scanned ? undefined : this.onCodeScanned}
|
||||||
type={RNCamera.Constants.Type.back}
|
type={RNCamera.Constants.Type.back}
|
||||||
barCodeTypes={['qr']}
|
barCodeTypes={[RNCamera.Constants.BarCodeType.qr]}
|
||||||
style={StyleSheet.absoluteFill}
|
style={StyleSheet.absoluteFill}
|
||||||
captureAudio={false}>
|
captureAudio={false}>
|
||||||
<BarcodeMask
|
<BarcodeMask
|
||||||
|
@ -194,15 +194,14 @@ class ScannerScreen extends React.Component<{}, StateType> {
|
||||||
/**
|
/**
|
||||||
* Opens scanned link if it is a valid app link or shows and error dialog
|
* Opens scanned link if it is a valid app link or shows and error dialog
|
||||||
*
|
*
|
||||||
* @param type The barcode type
|
* @param event
|
||||||
* @param data The scanned value
|
|
||||||
*/
|
*/
|
||||||
onCodeScanned = ({data}: {data: string}) => {
|
onCodeScanned = (event: BarCodeReadEvent) => {
|
||||||
if (!URLHandler.isUrlValid(data)) {
|
if (!URLHandler.isUrlValid(event.data)) {
|
||||||
this.showErrorDialog();
|
this.showErrorDialog();
|
||||||
} else {
|
} else {
|
||||||
this.showOpeningDialog();
|
this.showOpeningDialog();
|
||||||
Linking.openURL(data);
|
Linking.openURL(event.data);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue