Skip to content

Commit

Permalink
update example
Browse files Browse the repository at this point in the history
  • Loading branch information
sunnylqm committed Jul 29, 2024
1 parent 7531e8c commit 92bc830
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Example/testHotUpdate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"react-native-camera-kit": "^14.0.0-beta15",
"react-native-paper": "^5.12.1",
"react-native-safe-area-context": "^4.8.2",
"react-native-update": "^10.11.2",
"react-native-update": "^10.11.3",
"react-native-vector-icons": "^10.0.3"
},
"devDependencies": {
Expand Down
14 changes: 11 additions & 3 deletions Example/testHotUpdate/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable react/no-unstable-nested-components */
/* eslint-disable react-native/no-inline-styles */
import React, {useState} from 'react';
import React, {useRef, useState} from 'react';
import {
StyleSheet,
Platform,
Expand Down Expand Up @@ -47,6 +47,7 @@ function App() {
const snackbarVisible =
!useDefaultAlert && showUpdateSnackbar && updateInfo?.update;
const [showCamera, setShowCamera] = useState(false);
const lastParsedCode = useRef('');

return (
<View style={styles.container}>
Expand All @@ -73,9 +74,16 @@ function App() {
style={{minHeight: 320}}
scanBarcode={true}
onReadCode={({nativeEvent: {codeStringValue}}) => {
console.log(codeStringValue);
parseTestQrCode(codeStringValue);
// 防止重复扫码
if (lastParsedCode.current === codeStringValue) {
return;
}
lastParsedCode.current = codeStringValue;
setTimeout(() => {
lastParsedCode.current = '';
}, 1000);
setShowCamera(false);
parseTestQrCode(codeStringValue);
}} // optional
showFrame={true} // (default false) optional, show frame with transparent layer (qr code or barcode will be read on this area ONLY), start animation for scanner, that stops when a code has been found. Frame always at center of the screen
laserColor="red" // (default red) optional, color of laser in scanner frame
Expand Down
8 changes: 4 additions & 4 deletions Example/testHotUpdate/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6236,10 +6236,10 @@ react-native-safe-area-context@^4.8.2:
resolved "https://registry.yarnpkg.com/react-native-safe-area-context/-/react-native-safe-area-context-4.8.2.tgz#e6b3d8acf3c6afcb4b5db03a97f9c37df7668f65"
integrity sha512-ffUOv8BJQ6RqO3nLml5gxJ6ab3EestPiyWekxdzO/1MQ7NF8fW1Mzh1C5QE9yq573Xefnc7FuzGXjtesZGv7cQ==

react-native-update@^10.11.2:
version "10.11.2"
resolved "https://registry.yarnpkg.com/react-native-update/-/react-native-update-10.11.2.tgz#d80f0c0f3705713d302b6c36d3fd8ff2f0fba340"
integrity sha512-5WlJ3TRodHSftqDxi3OCAnI/OIq70Kh8gr1xa9OqEG2+UwD1SA+gqHRHunKED4J7N7OUtmxIDX+hvdf8xJEgRA==
react-native-update@^10.11.3:
version "10.11.3"
resolved "https://registry.yarnpkg.com/react-native-update/-/react-native-update-10.11.3.tgz#5fa44fdd12514eb5e7901a5d664f00fd082d6774"
integrity sha512-adI3sly0yFt1DfaPqICJ9VwzUoa/XAngv/N7SnICkLxO3jgccBgy0OrXDBxRn43Zeumdq40Z+ADTE5qrY4BWAw==
dependencies:
nanoid "^3.3.3"
react-native-url-polyfill "^2.0.0"
Expand Down

0 comments on commit 92bc830

Please sign in to comment.