import React, {useState} from 'react'; import {SafeAreaView, View} from 'react-native'; import {Colors} from 'react-native/Libraries/NewAppScreen'; import Settings from './Pages/Settings'; import Nfc from './Pages/Nfc'; import {UseScannerSession} from './utils'; import InitScanner from './Pages/InitScanner'; import {BottomNavigation, PaperProvider} from 'react-native-paper'; import {createBottomTabNavigator} from '@react-navigation/bottom-tabs'; //NfcManager.start(); const Tab = createBottomTabNavigator(); function App() { const {scannerSession, setScannerSession} = UseScannerSession(); const [selectedTab, setSelectedTab] = useState(''); // const [hasNfc, setHasNFC] = useState(false); //const [foundTag, setFoundTag] = useState(''); const colors = { nothingScanned: '#95a5a6', // gray input: '#9b59b6', // purple foundArticle: '#2ecc71', // green wrongArticle: '#c0392b', // red }; //const isDarkMode = useColorScheme() === 'dark'; const backgroundStyle = { backgroundColor: Colors.darker /*isDarkMode ? Colors.darker : Colors.lighter*/, }; /* useEffect(() => { const checkIsSupported = async () => { const deviceIsSupported = await NfcManager.isSupported(); setHasNFC(deviceIsSupported); if (deviceIsSupported) { await NfcManager.start(); } }; checkIsSupported(); NfcManager.setEventListener(NfcEvents.DiscoverTag, (tag: any) => { console.log( 'tag found', tag, Ndef.uri.decodePayload(tag.ndefMessage[0].payload), ); }); return () => { NfcManager.setEventListener(NfcEvents.DiscoverTag, null); }; }, []); const readTag = async () => { await NfcManager.registerTagEvent(); }; const writeNFC = async () => { let result = false; try { await NfcManager.requestTechnology(NfcTech.Ndef); const bytes = Ndef.encodeMessage([Ndef.uriRecord('https://umbach.dev')]); if (bytes) { await NfcManager.ndefHandler.writeNdefMessage(bytes); result = true; } } catch (ex) { console.warn(ex); } finally { NfcManager.cancelTechnologyRequest(); } return result; };*/ /* if (!hasNfc) { return ( NFC not supported ); } */ /* setSelectedTab('1')} selected={selectedTab === '1'}> {} setSelectedTab('2')} selected={selectedTab === '2'}> {} setSelectedTab('3')} selected={selectedTab === '3'}> {} */ const [index, setIndex] = useState(0); const [routes] = useState([ { key: 'nfc', title: 'NFC', }, {key: 'settings', title: 'Settings'}, ]); const NfcRoute = () => ; const SettingsRoute = () => ( ); const renderScene = BottomNavigation.SceneMap({ nfc: NfcRoute, settings: SettingsRoute, }); return ( {scannerSession === null || scannerSession === undefined ? ( ) : ( )} ); } export default App; /* Hello world Scan Tag Cancel Scan Write Tag */ /* { if (inputCode == '') { setInputCode(c => (c = data.data)); setMarkerStyleBorderColor(colors.input); Vibration.vibrate(500); setTimeout( () => setMarkerStyleBorderColor(colors.nothingScanned), 500, ); } else { setScannedCode(c => (c = data.data)); if (data.data == inputCode) { setMarkerStyleBorderColor(m => (m = colors.foundArticle)); Vibration.vibrate(100); setTimeout( () => setMarkerStyleBorderColor(colors.nothingScanned), 500, ); } else { setMarkerStyleBorderColor(m => (m = colors.wrongArticle)); Vibration.vibrate(300); setTimeout( () => setMarkerStyleBorderColor(colors.nothingScanned), 500, ); } } }} reactivate={true} reactivateTimeout={500} vibrate={false} cameraStyle={{overflow: 'hidden'}} markerStyle={{borderColor: markerStyleBorderColor, borderWidth: 5}} topViewStyle={{ alignItems: 'flex-start', justifyContent: 'flex-start', paddingLeft: 20, paddingTop: 20, paddingBottom: 20, flex: 1, }} topContent={ Desired article {inputCode} Scanned article {scannedCode} } bottomContent={ } /> */