Skip to content

Commit

Permalink
Fix eslint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
adityapawar1 committed Oct 5, 2024
1 parent 03ee9e4 commit 024ecb1
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
1 change: 1 addition & 0 deletions App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<RootStackParamList>();

Expand Down
16 changes: 10 additions & 6 deletions src/components/QRCodeScanner/QRCodeScanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<RootStackParamList, 'Scanner'>;
Expand All @@ -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.
Expand Down
1 change: 1 addition & 0 deletions src/components/TreeInfoPage/TreeInfoPage.tsx
Original file line number Diff line number Diff line change
@@ -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<
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Not sure where to keep this stuff
type RootStackParamList = {
export type RootStackParamList = {
Home: undefined;
Scanner: undefined;
TreeInfoPage: { treeId: string };
Expand Down

0 comments on commit 024ecb1

Please sign in to comment.