bug fixes + authentication screen

This commit is contained in:
Ksenia Lebedeva 2024-09-13 08:37:54 +02:00
parent b99803f639
commit 660960db1a
3 changed files with 29 additions and 5 deletions

View File

@ -8,6 +8,7 @@ import Keycard from "react-native-status-keycard";
import InitializationScreen from './components/steps/InitializationScreen';
import NFCModal from './NFCModal';
import MnemonicScreen from './components/steps/MnemonicScreen';
import AuthenticationScreen from './components/steps/AuthenticationScreen';
enum Step {
Discovery,
@ -115,6 +116,7 @@ const Main = () => {
{step == Step.Discovery && <DiscoveryScreen onPressFunc={connectCard}></DiscoveryScreen>}
{step == Step.Initialization && <InitializationScreen onPressFunc={initPin} ></InitializationScreen>}
{step == Step.Loading && <MnemonicScreen onPressFunc={loadMnemonic} pinRequired={pinRef.current ? false : true}></MnemonicScreen>}
{step == Step.Authentication && <AuthenticationScreen onPressFunc={() => {}}></AuthenticationScreen>}
<NFCModal isVisible={isModalVisible} onChangeFunc={setIsModalVisible}></NFCModal>
</SafeAreaView>
);

View File

@ -0,0 +1,26 @@
import {FC } from "react";
import { StyleSheet, Text, View } from "react-native";
type AuthenticationScreenProps = {
onPressFunc: () => void;
};
const AuthenticationScreen: FC<AuthenticationScreenProps> = props => {
const {onPressFunc} = props;
return (
<View>
<View>
<Text style={styles.heading}> Success</Text>
</View>
</View>
)};
const styles = StyleSheet.create({
heading: {
textAlign: 'center',
fontSize: 16
}
});
export default AuthenticationScreen;

View File

@ -18,16 +18,12 @@ const MnemonicScreen: FC<MnemonicScreenProps> = props => {
const [mnemonic, setMnemonic] = useState('');
const [pin, setPin] = useState('');
const [errMessage, setErrMessage] = useState('');
const [btnDisabled, setBtnDisabled] = useState(true);
const [step, setStep] = useState(LoadMnemonicSteps.InsertMnemonic);
const updateMnemonic = (str: string) => {
const mn = str.split(' ').filter((el: string) => el != "").map((word: string) => word.trim().toLowerCase());
const isInMnemonicList = (val: any) => MNEMONIC.includes(val);
console.log(mn)
if (!mn.every(isInMnemonicList)) {
if (!mn.every((val: string | any) => MNEMONIC.includes(val))) {
setErrMessage("Wrong mnemonic. Please try again.");
return;
}