Skip to content

Commit

Permalink
fix(index.ts): fix barcode finder area layout handler
Browse files Browse the repository at this point in the history
useRef was never actually updated. useState allows barcode layout to be updated.

fix #43
  • Loading branch information
nartc committed Feb 6, 2020
1 parent cf676ae commit f90baa9
Show file tree
Hide file tree
Showing 13 changed files with 21,020 additions and 12,265 deletions.
34 changes: 3 additions & 31 deletions example/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// @ts-check
/** @type {import("./@nartc/react-native-barcode-mask/src/index")} */

import React, {useRef, useState} from 'react';
import React, {useState} from 'react';
import {
Button,
SafeAreaView,
Expand All @@ -25,29 +25,8 @@ import {
} from './@nartc/react-native-barcode-mask/react-native-barcode-mask.esm';

const App = () => {
const rnCamera = useRef(null);
const [barcodeReadCount, setBarcodeReadCount] = useState(0);
const [barcodeReadAware, setBarcodeReadAware] = useState(false);
// const [barcodeRead, setBarcodeRead] = useState(false);
// const {onBarcodeFinderLayoutChange, onBarcodeRead} = useCustomBarcodeRead(
// true,
// data => data,
// processed => {
// console.log(processed, {barcodeReadCount});
// setBarcodeReadCount(prev => prev + 1);
// },
// {
// beforeScan: () => {
// setBarcodeRead(true);
// },
// afterScan: () => {},
// },
// (a, b, c) => {
// return event => {
// c(event.data);
// };
// },
// );
const {
barcodeRead,
onBarcodeRead,
Expand Down Expand Up @@ -90,7 +69,6 @@ const App = () => {
</View>
<Text>Barcode Read Count: {barcodeReadCount}</Text>
<RNCamera
ref={rnCamera}
androidCameraPermissionOptions={{
title: 'permissionCamera',
message: 'permissionCameraMessage',
Expand All @@ -99,19 +77,13 @@ const App = () => {
}}
style={styles.scanner}
type={RNCamera.Constants.Type.back}
barCodeTypes={
barcodeReadAware
? barcodeRead
? []
: [RNCamera.Constants.BarCodeType.qr]
: [RNCamera.Constants.BarCodeType.qr]
}
barCodeTypes={[RNCamera.Constants.BarCodeType.qr]}
onBarCodeRead={onBarcodeRead}
captureAudio={false}>
<BarcodeMaskWithOuterLayout
maskOpacity={0.5}
height={'80%'}
width={'80%'}
height={'80%'}
onLayoutChange={onBarcodeFinderLayoutChange}
/>
</RNCamera>
Expand Down
16 changes: 8 additions & 8 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,13 @@ PODS:
- React-cxxreact (= 0.61.5)
- React-jsi (= 0.61.5)
- React-jsinspector (0.61.5)
- react-native-camera (3.15.0):
- react-native-camera (3.17.0):
- React
- react-native-camera/RCT (= 3.15.0)
- react-native-camera/RN (= 3.15.0)
- react-native-camera/RCT (3.15.0):
- react-native-camera/RCT (= 3.17.0)
- react-native-camera/RN (= 3.17.0)
- react-native-camera/RCT (3.17.0):
- React
- react-native-camera/RN (3.15.0):
- react-native-camera/RN (3.17.0):
- React
- React-RCTActionSheet (0.61.5):
- React-Core/RCTActionSheetHeaders (= 0.61.5)
Expand Down Expand Up @@ -225,7 +225,7 @@ PODS:
- React-cxxreact (= 0.61.5)
- React-jsi (= 0.61.5)
- ReactCommon/jscallinvoker (= 0.61.5)
- RNReanimated (1.4.0):
- RNReanimated (1.7.0):
- React
- Yoga (1.14.0)

Expand Down Expand Up @@ -337,7 +337,7 @@ SPEC CHECKSUMS:
React-jsi: cb2cd74d7ccf4cffb071a46833613edc79cdf8f7
React-jsiexecutor: d5525f9ed5f782fdbacb64b9b01a43a9323d2386
React-jsinspector: fa0ecc501688c3c4c34f28834a76302233e29dc0
react-native-camera: 52114c432860b89986c9ee4919d00a48a6ba7abb
react-native-camera: 4ead7a30a89f275f531d80aa720cc69363c38135
React-RCTActionSheet: 600b4d10e3aea0913b5a92256d2719c0cdd26d76
React-RCTAnimation: 791a87558389c80908ed06cc5dfc5e7920dfa360
React-RCTBlob: d89293cc0236d9cb0933d85e430b0bbe81ad1d72
Expand All @@ -348,7 +348,7 @@ SPEC CHECKSUMS:
React-RCTText: 9ccc88273e9a3aacff5094d2175a605efa854dbe
React-RCTVibration: a49a1f42bf8f5acf1c3e297097517c6b3af377ad
ReactCommon: 198c7c8d3591f975e5431bec1b0b3b581aa1c5dd
RNReanimated: b2ab0b693dddd2339bd2f300e770f6302d2e960c
RNReanimated: 031fe8d9ea93c2bd689a40f05320ef9d96f74d7f
Yoga: f2a7cd4280bfe2cca5a7aed98ba0eb3d1310f18b

PODFILE CHECKSUM: 79310af6b976c356911a8a833e9b99c3399fdda3
Expand Down
Loading

0 comments on commit f90baa9

Please sign in to comment.