diff --git a/App.tsx b/App.tsx index d738060..b328b89 100644 --- a/App.tsx +++ b/App.tsx @@ -6,17 +6,17 @@ import {BarCodeEvent, BarCodeScanner, PermissionResponse} from 'expo-barcode-sca import * as firebase from 'firebase'; import 'firebase/firestore'; import React, {ReactElement, useCallback, useEffect, useState} from 'react'; -import {AppRegistry, SafeAreaView, View, YellowBox} from 'react-native'; +import {AppRegistry, SafeAreaView, Text, View, YellowBox} from 'react-native'; import { Appbar, Button, DefaultTheme, HelperText, - Provider as PaperProvider, + Provider as PaperProvider, RadioButton, Snackbar, Subheading, TextInput, - Title + Title, } from 'react-native-paper'; import {expo as appExpo} from './app.json'; import {CancelButton} from './components/Common'; @@ -24,7 +24,7 @@ import {BarCodeDisplay, PrintButton, PrintingMessage} from './components/Print'; import {IdNumberInput, InputIdButton, ScanButton, Scanner} from './components/Scan'; import {colors, styles} from './components/Styles'; import {BarcodeScannerAppState} from './models/BarcodeScannerAppState'; -import {ElementProps, StateProps} from './models/ElementProps'; +import {CameraType, ElementProps, StateProps} from './models/ElementProps'; import {Sample} from './models/Sample'; const firebaseConfig = { @@ -44,6 +44,7 @@ if (firebase.apps.length === 0) { YellowBox.ignoreWarnings([ 'Setting a timer for a long period of time', // Ignore Firebase timer warnings + 'Remote debugger is in a background tab', // Ignore Firebase timer warnings ]); const db = firebase.firestore(); @@ -62,6 +63,7 @@ export default function Main() { const [locationStr, setLocationStr] = useState('4321'); const [errorMessage, setErrorMessage] = useState(''); const [samples, setSamples] = useState([]); + const [cameraType, setCameraType] = useState('back'); useEffect(() => { BarCodeScanner.requestPermissionsAsync().then((value: PermissionResponse) => { @@ -110,6 +112,7 @@ export default function Main() { // Manually-entered ID numbers will be exactly 9 digits long. const barCodeString = e.data; const pattern = /^[\d]{14}$|^[\d]{9}$/; + console.log('barCodeString', barCodeString); if (pattern.test(barCodeString)) { const cardId = e.data.slice(0, 9); const newSampleDate = new Date(); @@ -168,13 +171,38 @@ export default function Main() { function SettingsScreen(props: ElementProps): ReactElement { const [inputStr, setInputStr] = useState(locationStr); + const pattern = /^[\d]{4}$/; const hasErrors = () => { return !pattern.test(inputStr); }; return - Settings + + Which camera to scan bar codes with? + setCameraType(value as CameraType)} + value={cameraType as string} + > + + Front + + + + Back + + + + + Please do NOT change this unless you know what you are doing. Entering an incorrect location number may @@ -264,11 +292,13 @@ export default function Main() { return ; case BarcodeScannerAppState.INPUT: return ; case BarcodeScannerAppState.SETTINGS: return ; diff --git a/app.json b/app.json index e1ffc1f..6154740 100644 --- a/app.json +++ b/app.json @@ -4,7 +4,7 @@ "name": "uva-covid19-testing-kiosk", "slug": "uva-covid19-testing-kiosk", "version": "1.0.0", - "orientation": "portrait", + "orientation": "landscape", "icon": "./assets/icon.png", "splash": { "image": "./assets/splash.png", @@ -19,7 +19,8 @@ ], "ios": { "supportsTablet": true, - "bundleIdentifier": "com.sartography.uvacovid19testingkiosk" + "bundleIdentifier": "com.sartography.uvacovid19testingkiosk", + "requireFullScreen": true }, "web": { "favicon": "./assets/favicon.png" @@ -34,4 +35,4 @@ "package": "com.sartography.uvacovid19testingkiosk" } } -} \ No newline at end of file +} diff --git a/components/Scan.tsx b/components/Scan.tsx index edbf618..10d3d58 100644 --- a/components/Scan.tsx +++ b/components/Scan.tsx @@ -5,52 +5,32 @@ import {Button, DefaultTheme, HelperText, Subheading, TextInput, Title} from 're import {ButtonProps, ScannerProps} from '../models/ElementProps'; import {colors, styles} from './Styles'; -declare type CameraType = number | 'front' | 'back' | undefined; export const Scanner = (props: ScannerProps): ReactElement => { - const [componentKey, setComponentKey] = useState(0); - const [cameraType, setCameraType] = useState('back'); - - const _toggleCameraType = () => { - setCameraType(cameraType === 'front' ? 'back' : 'front'); - setComponentKey(componentKey + 1); - } - - const ScanCamera = (): ReactElement => { - return - - - - - - - - Hold your ID card up, with the barcode facing the camera. Keep the card in the green box. - - - - - - ; - } - - return ; + return + + + + + + + + Hold your ID card up, with the barcode facing the camera. Keep the card in the green box. + + + + + ; }; export const ScanButton = (props: ButtonProps): ReactElement => { @@ -70,6 +50,7 @@ export const InputIdButton = (props: ButtonProps): ReactElement => { mode="text" color={colors.onBackground} onPress={props.onClicked} + style={{marginTop: 30}} >Enter ID Number Manually; }; @@ -85,7 +66,7 @@ export const IdNumberInput = (props: ScannerProps): ReactElement => { } return - Settings + Manual ID # Entry Please double check that you have entered the number correctly. Entering an incorrect ID number will prevent diff --git a/models/ElementProps.tsx b/models/ElementProps.tsx index 8527ed1..d697916 100644 --- a/models/ElementProps.tsx +++ b/models/ElementProps.tsx @@ -1,6 +1,9 @@ import {BarCodeScannedCallback} from 'expo-barcode-scanner'; import {BarcodeScannerAppState} from './BarcodeScannerAppState'; +export declare type CameraType = number | 'front' | 'back' | undefined; +export declare type CheckedStatus ='checked' | 'unchecked' | undefined; + export interface ElementProps { title?: string; } @@ -23,6 +26,7 @@ export interface ButtonProps extends ElementProps { export interface ScannerProps extends ElementProps { onScanned: BarCodeScannedCallback; onCancel: () => void; + cameraType: CameraType; } export interface PrintingProps extends BarCodeProps { diff --git a/package.json b/package.json index 0e0cceb..62c928a 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "expo": "~38.0.8", "expo-barcode-scanner": "~8.2.1", "expo-print": "~9.0.1", + "expo-screen-orientation": "~1.1.1", "expo-splash-screen": "^0.5.0", "expo-status-bar": "^1.0.2", "expo-updates": "~0.2.10", diff --git a/yarn.lock b/yarn.lock index 8753165..7f68e56 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4334,6 +4334,13 @@ expo-print@~9.0.1: resolved "https://registry.yarnpkg.com/expo-print/-/expo-print-9.0.2.tgz#1138bbc0dc94799962980cdc9c09475ba4943d4d" integrity sha512-Jk8Q4QOdkCGY4zqr+omLMnsX5FPQYz6Ug2TfUeAixwPfJuNuGUPPvWiQhucxV4idS0C1nHh4HAXj+S27zDZwig== +expo-screen-orientation@~1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/expo-screen-orientation/-/expo-screen-orientation-1.1.1.tgz#515776e534530efdb716e56ec0c47cf8fb9de82f" + integrity sha512-o3RhmidIhVK4lXHVActnO2iD0ZrZKxzWuRrJaTSpRsvRjCabeE74xkpZWPGcEcXhAxEwMaAAizHO8rlJDdrVzw== + dependencies: + fbjs "1.0.0" + expo-splash-screen@^0.5.0: version "0.5.0" resolved "https://registry.yarnpkg.com/expo-splash-screen/-/expo-splash-screen-0.5.0.tgz#cad0eb77a3eade2c7101d169b8655e7ee8053c2f" @@ -7589,7 +7596,12 @@ q@^1.1.2: resolved "https://registry.yarnpkg.com/q/-/q-1.5.1.tgz#7e32f75b41381291d04611f1bf14109ac00651d7" integrity sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc= -qrcode@^1.3.2: +qrcode-svg@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/qrcode-svg/-/qrcode-svg-1.1.0.tgz#2087549843dc5d0a3f8e8aa046cd9bcf23708cc3" + integrity sha512-XyQCIXux1zEIA3NPb0AeR8UMYvXZzWEhgdBgBjH9gO7M48H9uoHzviNz8pXw3UzrAcxRRRn9gxHewAVK7bn9qw== + +qrcode@^1.3.2, qrcode@^1.4.4: version "1.4.4" resolved "https://registry.yarnpkg.com/qrcode/-/qrcode-1.4.4.tgz#f0c43568a7e7510a55efc3b88d9602f71963ea83" integrity sha512-oLzEC5+NKFou9P0bMj5+v6Z40evexeE29Z9cummZXZ9QXyMr3lphkURzxjXgPJC5azpxcshoDWV1xE46z+/c3Q==