import React, { useState, useRef } from 'react'; import * as Haptics from 'expo-haptics'; import { gestureHandlerRootHOC } from 'react-native-gesture-handler'; import Base from './Base'; import { TYPE } from './constants'; import I18n from '../../i18n'; interface IPasscodeChoose { theme: string; force: boolean; finishProcess: Function; } const PasscodeChoose = ({ theme, finishProcess, force = false }: IPasscodeChoose) => { const chooseRef = useRef(null); const confirmRef = useRef(null); const [subtitle, setSubtitle] = useState(null); const [status, setStatus] = useState(TYPE.CHOOSE); const [previousPasscode, setPreviouPasscode] = useState(null); const firstStep = (p: any) => { setTimeout(() => { setStatus(TYPE.CONFIRM); setPreviouPasscode(p); confirmRef?.current?.clearPasscode(); }, 200); }; const changePasscode = (p: string) => finishProcess && finishProcess(p); const onError = () => { setTimeout(() => { setStatus(TYPE.CHOOSE); setSubtitle(I18n.t('Passcode_choose_error')); chooseRef?.current?.animate('shake'); chooseRef?.current?.clearPasscode(); Haptics.notificationAsync(Haptics.NotificationFeedbackType.Error); }, 200); }; if (status === TYPE.CONFIRM) { return ( // @ts-ignore ); } return ( // @ts-ignore ); }; export default gestureHandlerRootHOC(PasscodeChoose);