update nfc handling
This commit is contained in:
parent
b542c32e6d
commit
9c8ca28e2f
|
@ -13,7 +13,7 @@
|
|||
"react": "18.3.1",
|
||||
"react-native": "0.75.3",
|
||||
"react-native-modal": "^13.0.1",
|
||||
"react-native-status-keycard": "git+https://github.com/status-im/react-native-status-keycard.git#refs/tags/v2.6.0",
|
||||
"react-native-status-keycard": "git+https://github.com/status-im/react-native-status-keycard.git#refs/tags/v2.6.1",
|
||||
"react-native-vector-icons": "^10.1.0",
|
||||
"react-native-vision-camera": "^4.5.3"
|
||||
},
|
||||
|
@ -6666,9 +6666,9 @@
|
|||
"license": "MIT"
|
||||
},
|
||||
"node_modules/electron-to-chromium": {
|
||||
"version": "1.5.29",
|
||||
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.29.tgz",
|
||||
"integrity": "sha512-PF8n2AlIhCKXQ+gTpiJi0VhcHDb69kYX4MtCiivctc2QD3XuNZ/XIOlbGzt7WAjjEev0TtaH6Cu3arZExm5DOw==",
|
||||
"version": "1.5.30",
|
||||
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.30.tgz",
|
||||
"integrity": "sha512-sXI35EBN4lYxzc/pIGorlymYNzDBOqkSlVRe6MkgBsW/hW1tpC/HDJ2fjG7XnjakzfLEuvdmux0Mjs6jHq4UOA==",
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/emittery": {
|
||||
|
@ -7206,9 +7206,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/eslint-plugin-react": {
|
||||
"version": "7.37.0",
|
||||
"resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.37.0.tgz",
|
||||
"integrity": "sha512-IHBePmfWH5lKhJnJ7WB1V+v/GolbB0rjS8XYVCSQCZKaQCAUhMoVoOEn1Ef8Z8Wf0a7l8KTJvuZg5/e4qrZ6nA==",
|
||||
"version": "7.37.1",
|
||||
"resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.37.1.tgz",
|
||||
"integrity": "sha512-xwTnwDqzbDRA8uJ7BMxPs/EXRB3i8ZfnOIp8BsxEQkT0nHPp+WWceqGgo6rKb9ctNi8GJLDT4Go5HAWELa/WMg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
|
@ -13012,8 +13012,8 @@
|
|||
}
|
||||
},
|
||||
"node_modules/react-native-status-keycard": {
|
||||
"version": "2.6.0",
|
||||
"resolved": "git+ssh://git@github.com/status-im/react-native-status-keycard.git#7da38ff5f7c6b821445765466c40f2562b55da4b",
|
||||
"version": "2.6.1",
|
||||
"resolved": "git+ssh://git@github.com/status-im/react-native-status-keycard.git#2f9d46b2c720a8f2d76b510259bf8f538463ffa3",
|
||||
"license": "MPL 2.0"
|
||||
},
|
||||
"node_modules/react-native-vector-icons": {
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
"react": "18.3.1",
|
||||
"react-native": "0.75.3",
|
||||
"react-native-modal": "^13.0.1",
|
||||
"react-native-status-keycard": "git+https://github.com/status-im/react-native-status-keycard.git#refs/tags/v2.6.0",
|
||||
"react-native-status-keycard": "git+https://github.com/status-im/react-native-status-keycard.git#refs/tags/v2.6.1",
|
||||
"react-native-vector-icons": "^10.1.0",
|
||||
"react-native-vision-camera": "^4.5.3"
|
||||
},
|
||||
|
|
16
src/Main.tsx
16
src/Main.tsx
|
@ -37,7 +37,6 @@ const Main = () => {
|
|||
const stepRef = useRef(step);
|
||||
const pinRef = useRef("");
|
||||
const mnemonicRef = useRef("");
|
||||
const isListeningCard = useRef(false);
|
||||
const walletKey = useRef("");
|
||||
const sessionRef = useRef("")
|
||||
const challengeRef = useRef("")
|
||||
|
@ -88,10 +87,6 @@ const Main = () => {
|
|||
}
|
||||
|
||||
const keycardConnectHandler = async () => {
|
||||
if (!isListeningCard.current) {
|
||||
return;
|
||||
}
|
||||
|
||||
var newPinCounter = pinCounter;
|
||||
var loginReq = "";
|
||||
|
||||
|
@ -162,8 +157,7 @@ const Main = () => {
|
|||
|
||||
setPinCounter(newPinCounter);
|
||||
|
||||
await Keycard.stopNFC("");
|
||||
setIsModalVisible(false);
|
||||
await stopNFC();
|
||||
|
||||
if (loginReq) {
|
||||
console.log(loginReq);
|
||||
|
@ -189,7 +183,6 @@ const Main = () => {
|
|||
|
||||
useEffect(() => {
|
||||
stepRef.current = step;
|
||||
isListeningCard.current = isModalVisible;
|
||||
|
||||
const eventEmitter = new NativeEventEmitter(Keycard);
|
||||
let onConnectedListener = eventEmitter.addListener('keyCardOnConnected', keycardConnectHandler);
|
||||
|
@ -265,6 +258,11 @@ const Main = () => {
|
|||
return pinCounter == PIN_MAX_RETRY ? -1 : pinCounter;
|
||||
}
|
||||
|
||||
const stopNFC = async () => {
|
||||
await Keycard.stopNFC("");
|
||||
setIsModalVisible(false);
|
||||
}
|
||||
|
||||
return (
|
||||
<SafeAreaView style={styles.container}>
|
||||
{step == Step.Discovery && <DiscoveryScreen onPressFunc={connectCard} onFactoryResetFunc={startFactoryReset}></DiscoveryScreen>}
|
||||
|
@ -273,7 +271,7 @@ const Main = () => {
|
|||
{step == Step.Authentication && <Dialpad pinRetryCounter={pinDisplayCounter()} prompt={"Choose PIN"} onCancelFunc={cancel} onNextFunc={authenticate}></Dialpad>}
|
||||
{step == Step.Home && <HomeScreen walletKey={walletKey.current} onPressFunc={login} onCancelFunc={cancel}></HomeScreen>}
|
||||
{step == Step.FactoryReset && <FactoryResetScreen pinRetryCounter={pinDisplayCounter()} onPressFunc={connectCard} onCancelFunc={cancel}></FactoryResetScreen>}
|
||||
<NFCModal isVisible={isModalVisible} onChangeFunc={setIsModalVisible}></NFCModal>
|
||||
<NFCModal isVisible={isModalVisible} onChangeFunc={stopNFC}></NFCModal>
|
||||
</SafeAreaView>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import Button from "./components/Button";
|
|||
|
||||
type NFCModalProps = {
|
||||
isVisible: boolean;
|
||||
onChangeFunc: (val: boolean) => void;
|
||||
onChangeFunc: () => void;
|
||||
};
|
||||
|
||||
const NFCModal: FC<NFCModalProps> = props => {
|
||||
|
@ -20,7 +20,7 @@ const NFCModal: FC<NFCModalProps> = props => {
|
|||
<Icon name="smartphone" size={40} style={modalStyle.icon}/>
|
||||
</View>
|
||||
<Text style={modalStyle.prompt}>Tap your Keycard</Text>
|
||||
<Button label="Cancel" disabled={false} btnColor="white" btnBorderColor="white" btnFontSize={13} btnBorderWidth={1} btnWidth="100%" onChangeFunc={() => onChangeFunc(!isVisible)} btnJustifyContent='center'></Button>
|
||||
<Button label="Cancel" disabled={false} btnColor="white" btnBorderColor="white" btnFontSize={13} btnBorderWidth={1} btnWidth="100%" onChangeFunc={() => onChangeFunc()} btnJustifyContent='center'></Button>
|
||||
</View>
|
||||
</Modal>
|
||||
)};
|
||||
|
|
Loading…
Reference in New Issue