From 7cf182fe11cdc530e3c24efe1b08938abf25cb1b Mon Sep 17 00:00:00 2001 From: Aaron Louie Date: Thu, 3 Sep 2020 18:27:44 -0400 Subject: [PATCH] Prints QR Code Former-commit-id: d6f5be66263cc38ba56f0dd5e268ef0facd80800 --- App.tsx | 21 ++---- components/Print.tsx | 81 ++++++++++++++------ components/Scan.tsx | 12 +-- components/Styles.tsx | 5 +- models/ElementProps.tsx | 1 - package-lock.json | 158 +++++++++++++++++++++++++++++++++++----- package.json | 2 + 7 files changed, 215 insertions(+), 65 deletions(-) diff --git a/App.tsx b/App.tsx index ebe1c35..ee7d30e 100644 --- a/App.tsx +++ b/App.tsx @@ -18,7 +18,6 @@ import { TextInput, Title } from 'react-native-paper'; -import QRCode from 'react-native-qrcode-svg'; import {expo as appExpo} from './app.json'; import {CancelButton} from './components/Common'; import {BarCodeDisplay, PrintButton, PrintingMessage} from './components/Print'; @@ -61,7 +60,6 @@ export default function Main() { const [barCodeId, setBarCodeId] = useState(''); const [sampleDate, setSampleDate] = useState(new Date()); const [locationStr, setLocationStr] = useState('4321'); - const [svgQrCode, setSvgQrCode] = useState(); const [errorMessage, setErrorMessage] = useState(''); const [samples, setSamples] = useState([]); @@ -114,16 +112,13 @@ export default function Main() { const pattern = /^[\d]{14}$|^[\d]{9}$/; if (pattern.test(barCodeString)) { const cardId = e.data.slice(0, 9); - setBarCodeId(cardId); - setSampleDate(new Date()); - setAppState(BarcodeScannerAppState.SCANNED); - setSampleId([barCodeId, format(sampleDate, 'yyyyMMddHHmm'), locationStr].join('-')); + const newSampleDate = new Date(); + const newSampleId = [cardId, format(newSampleDate, 'yyyyMMddHHmm'), locationStr].join('-'); - console.log('sampleId', sampleId); - new QRCode({value: sampleId, ecl: 'H', getRef: c => { - setSvgQrCode(c); - console.log('svgQrCode', svgQrCode); - }}); + setSampleId(newSampleId); + setBarCodeId(cardId); + setSampleDate(newSampleDate); + setAppState(BarcodeScannerAppState.SCANNED); } else { setErrorMessage(`The barcode data "${e.data}" is not from a valid ID card.`); setAppState(BarcodeScannerAppState.ERROR); @@ -196,7 +191,7 @@ export default function Main() { Location number must be exactly 4 digits. No other characters are allowed.