feat: update app configuration and enhance UI components
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import React, { useEffect, useRef } from 'react';
|
||||
import { Modal, Text, TouchableOpacity, View, Animated, Easing, Vibration, Alert } from 'react-native';
|
||||
import { X, Radio, SmartphoneNfc } from 'lucide-react-native';
|
||||
import NfcManager, { NfcTech } from 'react-native-nfc-manager';
|
||||
import NfcManager, { Ndef, NfcTech } from 'react-native-nfc-manager';
|
||||
|
||||
interface NfcScanModalProps {
|
||||
visible: boolean;
|
||||
@@ -31,9 +31,16 @@ export default function NfcScanModal({ visible, onClose, onScan }: NfcScanModalP
|
||||
const tag = await NfcManager.getTag();
|
||||
|
||||
if (tag) {
|
||||
console.log('NFC Tag Found:', tag);
|
||||
const record = tag.ndefMessage?.[0];
|
||||
const payloadBytes = new Uint8Array(record.payload);
|
||||
const text = Ndef.text.decodePayload(payloadBytes);
|
||||
console.log('NFC text:', text || 'No NDEF payload');
|
||||
Vibration.vibrate();
|
||||
// onScan(tag.id || JSON.stringify(tag));
|
||||
if (!text) {
|
||||
Alert.alert('Errore', 'Tag NFC non contiene dati validi.');
|
||||
throw new Error('Empty NFC tag');
|
||||
}
|
||||
onScan(text);
|
||||
onClose();
|
||||
} else {
|
||||
console.warn('Tag NFC vuoto o non formattato NDEF');
|
||||
|
||||
Reference in New Issue
Block a user