UNPKG

je_nfc_sdk

Version:

A comprehensive React Native SDK for NFC-based device control and communication

31 lines (30 loc) 949 B
import { jsx as _jsx } from "react/jsx-runtime"; import { TouchableOpacity, Text, StyleSheet } from 'react-native'; import { NfcService } from '../logic/NfcService'; export const NfcScanButton = ({ onResult }) => { const handleScan = async () => { try { const tag = await NfcService.scanTag(); onResult(tag); } catch (e) { console.warn('Scan failed', e); } finally { await NfcService.stop(); } }; return (_jsx(TouchableOpacity, Object.assign({ onPress: handleScan, style: styles.button }, { children: _jsx(Text, Object.assign({ style: styles.text }, { children: "\uD83D\uDD0D Scan NFC" })) }))); }; const styles = StyleSheet.create({ button: { padding: 12, backgroundColor: '#16a2b8', borderRadius: 8, alignItems: 'center', }, text: { color: '#fff', fontWeight: 'bold', }, });