diff --git a/amnet-native/App.tsx b/amnet-native/App.tsx
index e3a77ea..c5b16bc 100644
--- a/amnet-native/App.tsx
+++ b/amnet-native/App.tsx
@@ -121,7 +121,7 @@ export default function AppRoot() {
-
+
diff --git a/amnet-native/app/ServerCardIn.tsx b/amnet-native/app/ServerCardIn.tsx
index baa5e61..f60b69e 100644
--- a/amnet-native/app/ServerCardIn.tsx
+++ b/amnet-native/app/ServerCardIn.tsx
@@ -1,4 +1,5 @@
import {BSON} from "realm";
+import NfcManager from "react-native-nfc-manager";
import React, {useCallback, useEffect, useLayoutEffect, useMemo, useState} from "react";
import {ActivityIndicator, Button, IconButton, Paragraph, Title, useTheme} from "react-native-paper";
import {Platform, RefreshControl, ScrollView, Share, StyleSheet, Text, TouchableOpacity, View} from "react-native";
@@ -43,6 +44,16 @@ export default function ServerCardIn({route, navigation}) {
query: q => q.sorted("lastUsed", true)
});
+ // nfc support
+ const [nfcSupported, setNfcSupported] = useState(Platform.OS === 'android' ? false : null);
+ useEffect(() => {
+ if (nfcSupported !== null) {
+ return;
+ }
+
+ NfcManager.isSupported().then(setNfcSupported);
+ }, []);
+
// server state
const [serverRefreshing, setServerRefreshing] = useState(false);
const [serverReloadCounter, setServerReloadCounter] = useState(0);
@@ -201,12 +212,12 @@ export default function ServerCardIn({route, navigation}) {
}
return (
- }>
+ }>
- {server.gameId ? `Play ${getGameName(server.gameId)}` : "Selected Card"}
+ {server.gameId ? `Play ${getGameName(server.gameId)}` : "Selected Card"}
{selectedCard ? <>
}
-
- {Platform.OS === 'ios' && (
+ {nfcSupported === true && (
}
onPress={() => navigation.navigate('add-card')}>
- Add card
+ Add Card
- }
+
+ }
{cards.length > 0 && (
@@ -251,8 +263,8 @@ export default function ServerCardIn({route, navigation}) {
diff --git a/amnet-native/app/card/CardAddModal.tsx b/amnet-native/app/card/CardAddModal.tsx
index 7bdc2d7..4bef1e3 100644
--- a/amnet-native/app/card/CardAddModal.tsx
+++ b/amnet-native/app/card/CardAddModal.tsx
@@ -1,7 +1,6 @@
-import React from "react";
+import NfcManager from "react-native-nfc-manager";
import {Platform, TouchableOpacity, View} from "react-native";
-
-import {useNavigation} from "@react-navigation/native";
+import React, {useEffect, useLayoutEffect, useState} from "react";
import {createNativeStackNavigator} from "@react-navigation/native-stack";
import {Card, Paragraph, Text, Title, useTheme} from "react-native-paper";
@@ -23,25 +22,41 @@ function CardAddModal() {
)
}
-function CardAddMethodSelector() {
+function CardAddMethodSelector({navigation}) {
const theme = useTheme();
- const navigation: any = useNavigation();
+ const [nfcSupported, setNfcSupported] = useState(null);
+
+ useLayoutEffect(() => {
+ navigation.setOptions({
+ headerShown: false
+ });
+ }, []);
+
+ useEffect(() => {
+ NfcManager.isSupported().then(setNfcSupported);
+ }, []);
return (
Add new Card
- AMNet supports scanning physical cards, entering details
- manually or generating new ones.
+
+ AMNet supports scanning physical cards, entering details manually or generating new ones.
+
- }
- title="Scan Physical Card"
- description="Amusement IC or Transport cards supported"
- onPress={() => navigation.navigate('Scan')}/>
+ {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')}/>
-
+
+ >
+ )}
}
@@ -60,6 +75,7 @@ function MethodCard(props: {
title: string,
description?: string,
color: string,
+ disabled?: boolean,
icon: React.ReactElement,
onPress: () => void
}) {
@@ -67,8 +83,8 @@ function MethodCard(props: {
const large = props.description?.length > 0;
return (
- props.onPress()}>
-
+ !props.disabled && props.onPress()} disabled={props.disabled}>
+