Paraboly / react-native-barcode-scanner

MIT License
19 stars 3 forks source link

Does not recognise barcode or log to console #12

Open foxorajack opened 2 years ago

foxorajack commented 2 years ago

My code:

import React, { useEffect, useState } from 'react';
import { ... } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { BottomTabBar } from '@react-navigation/bottom-tabs'
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { Icon } from 'react-native-elements';

import BarcodeScanner from "@paraboly/react-native-barcode-scanner";

const App = () =>  {
  const isDarkMode = useColorScheme() === 'dark';

  const backgroundStyle = {
    backgroundColor: isDarkMode ? Colors.black : Colors.lighter,
  };

  return (
    <View style={styles.masterContainer}>
      <View style={styles.mainContainer}>
        <NavigationContainer>
              <Stack.Navigator screenOptions={({ route }) => ({
                  headerShown: false
                })}>
                <Stack.Screen name="Home" component={HomeTabs} />
                <Stack.Screen name="Job Page" component={JobPage} />
              </Stack.Navigator>
        </NavigationContainer>
      </View>
    </View>
  );
};

function HomeTabs() {
  const isDarkMode = useColorScheme() === 'dark';
  return (
    <Tab.Navigator screenOptions={({ route }) => ({
        headerShown: false
      })>
      <Tab.Screen name="ScannerPage" component={ScannerPage} />
    </Tab.Navigator>
  )
}

const ScannerPage = ({ navigation, route  }) => {
  const isDarkMode = useColorScheme() === 'dark';
  return (
    <BarcodeScanner
      onGoogleVisionBarcodesDetected={({ barcodes }) => {
        console.log("Barcode: ", barcodes[0].data);
      }}
    />
  );
}

const styles = StyleSheet.create({ ... });

export default App;

The camera renders, but does not scan the barcode.

foxorajack commented 2 years ago

@WrathChaos - help would be much appreciated 🙏

WrathChaos commented 2 years ago

Hello sir, since I'm not part of the project and the company anymore I cannot update the library itself. However, let me fork it and let's see what we can do @foxorajack