From 024ecb1baee3b84d13c28553446e61677d07793d Mon Sep 17 00:00:00 2001 From: Aditya Pawar Date: Sat, 5 Oct 2024 13:28:19 -0700 Subject: [PATCH] Fix eslint errors --- App.tsx | 1 + src/components/QRCodeScanner/QRCodeScanner.tsx | 16 ++++++++++------ src/components/TreeInfoPage/TreeInfoPage.tsx | 1 + src/types.ts | 2 +- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/App.tsx b/App.tsx index 7f2b58d..c94b086 100644 --- a/App.tsx +++ b/App.tsx @@ -4,6 +4,7 @@ import { createNativeStackNavigator } from '@react-navigation/native-stack'; import HomeScreen from '@/app'; import QRCodeScanner from '@/components/QRCodeScanner/QRCodeScanner'; import TreeInfoPage from '@/components/TreeInfoPage/TreeInfoPage'; +import { RootStackParamList } from '@/types'; const Stack = createNativeStackNavigator(); diff --git a/src/components/QRCodeScanner/QRCodeScanner.tsx b/src/components/QRCodeScanner/QRCodeScanner.tsx index 0fc3be4..855f032 100644 --- a/src/components/QRCodeScanner/QRCodeScanner.tsx +++ b/src/components/QRCodeScanner/QRCodeScanner.tsx @@ -6,6 +6,7 @@ import { useCameraPermissions, } from 'expo-camera'; import { NativeStackScreenProps } from '@react-navigation/native-stack'; +import { RootStackParamList } from '@/types'; import styles from './styles'; type QRCodeScannerProps = NativeStackScreenProps; @@ -19,25 +20,28 @@ export default function QRCodeScanner({ navigation }: QRCodeScannerProps) { if (!permission?.granted) { requestPermission(); } - }, [permission]); + }, [permission, requestPermission]); const onBarcodeScanned = (data: BarcodeScanningResult) => { // Disable scanning callback so we don't scan multiple times setDisableScanner(true); Alert.alert( - 'YUHHHHH QR Code Scanned', - `Going to tree page with id: ${data.data}`, + 'Found Tree QR Code!', + `Would you like to view more information about tree ${data.data}?`, [ + { + text: 'Cancel', + // Enable scanner after 2 seconds of pressing Cancel + onPress: () => setTimeout(() => setDisableScanner(false), 2000), + style: 'cancel', + }, { text: 'OK', - // Enable scanner after 2 seconds of pressing OK onPress: () => navigation.push('TreeInfoPage', { treeId: data.data }), }, ], ); - - // setTimeout(() => setDisableScanner(false), 2000), }; // Camera permissions are still loading. diff --git a/src/components/TreeInfoPage/TreeInfoPage.tsx b/src/components/TreeInfoPage/TreeInfoPage.tsx index c26facc..7c78e4a 100644 --- a/src/components/TreeInfoPage/TreeInfoPage.tsx +++ b/src/components/TreeInfoPage/TreeInfoPage.tsx @@ -1,6 +1,7 @@ import { Pressable, Text, View } from 'react-native'; import { StatusBar } from 'expo-status-bar'; import { NativeStackScreenProps } from '@react-navigation/native-stack'; +import { RootStackParamList } from '@/types'; import styles from './styles'; type TreeInfoPageProps = NativeStackScreenProps< diff --git a/src/types.ts b/src/types.ts index a334e1e..e94f9f5 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,5 +1,5 @@ // Not sure where to keep this stuff -type RootStackParamList = { +export type RootStackParamList = { Home: undefined; Scanner: undefined; TreeInfoPage: { treeId: string };