import NfcManager from "react-native-nfc-manager"; import React, {useEffect, useState} from "react"; import {Platform, TouchableOpacity, View} from "react-native"; import {createNativeStackNavigator} from "@react-navigation/native-stack"; import {Card, Paragraph, Text, Title, useTheme} from "react-native-paper"; import {SmartphoneNfc, SquareAsterisk, SquarePlus} from "lucide-react-native"; import ManualCardEntry from "./ManualCardEntry"; import PhysicalCardScan from "./PhyscialCardScan"; const Stack = createNativeStackNavigator(); function CardAddModal() { return ( ) } function CardAddMethodSelector({navigation}) { const theme = useTheme(); const [nfcSupported, setNfcSupported] = useState(null); useEffect(() => { NfcManager.isSupported().then(setNfcSupported); }, []); return ( Add new Card AMNet supports scanning physical cards, entering details manually or generating new ones. {nfcSupported !== null && ( <> } disabled={!nfcSupported} title="Scan Physical Card" description={nfcSupported ? "Amusement IC or Transport cards supported" : "NFC is not supported on this device"} onPress={() => navigation.navigate('Scan')}/> )} } title="Enter Details Manually" onPress={() => navigation.navigate('Manual')}/> } title="Generate New Card" onPress={() => navigation.navigate('Manual', {autoGenerate: true})}/> ) } function MethodCard(props: { title: string, description?: string, color: string, disabled?: boolean, icon: React.ReactElement, onPress: () => void }) { const theme = useTheme(); const large = props.description?.length > 0; return ( !props.disabled && props.onPress()} disabled={props.disabled}> {React.cloneElement(props.icon, {size: large ? 24 : 16, color: theme.colors.surfaceVariant})} {props.title} {props.description && ({props.description})} ) } // the nfc library doesn't offer the same support for felica cards on android compared to ios... export default Platform.OS === 'ios' ? CardAddModal : ManualCardEntry;