Show whole passcode

This commit is contained in:
Diego Mello 2020-04-27 15:15:00 -03:00
parent 47a5909653
commit 3245fca204
2 changed files with 18 additions and 9 deletions

View File

@ -22,8 +22,10 @@ const Base = forwardRef(({
const dotsRef = useRef(); const dotsRef = useRef();
const [passcode, setPasscode] = useState(''); const [passcode, setPasscode] = useState('');
const clearPasscode = () => setPasscode('');
const wrongPasscode = () => { const wrongPasscode = () => {
setPasscode(''); clearPasscode();
dotsRef?.current?.shake(500); dotsRef?.current?.shake(500);
Haptics.notificationAsync(Haptics.NotificationFeedbackType.Error); Haptics.notificationAsync(Haptics.NotificationFeedbackType.Error);
}; };
@ -52,7 +54,6 @@ const Base = forwardRef(({
default: default:
break; break;
} }
return '';
} }
return currentPasscode; return currentPasscode;
}); });
@ -66,7 +67,7 @@ const Base = forwardRef(({
}); });
useImperativeHandle(ref, () => ({ useImperativeHandle(ref, () => ({
wrongPasscode, animate wrongPasscode, animate, clearPasscode
})); }));
return ( return (

View File

@ -7,23 +7,30 @@ import { TYPE } from './constants';
import I18n from '../../i18n'; import I18n from '../../i18n';
const PasscodeEnter = ({ theme, finishProcess }) => { const PasscodeEnter = ({ theme, finishProcess }) => {
const chooseRef = useRef(null);
const confirmRef = useRef(null); const confirmRef = useRef(null);
const [subtitle, setSubtitle] = useState(null); const [subtitle, setSubtitle] = useState(null);
const [status, setStatus] = useState(TYPE.CHOOSE); const [status, setStatus] = useState(TYPE.CHOOSE);
const [previousPasscode, setPreviouPasscode] = useState(null); const [previousPasscode, setPreviouPasscode] = useState(null);
const firstStep = (p) => { const firstStep = (p) => {
setTimeout(() => {
setStatus(TYPE.CONFIRM); setStatus(TYPE.CONFIRM);
setPreviouPasscode(p); setPreviouPasscode(p);
confirmRef?.current?.clearPasscode();
}, 200);
}; };
const changePasscode = p => finishProcess && finishProcess(p); const changePasscode = p => finishProcess && finishProcess(p);
const onError = () => { const onError = () => {
setTimeout(() => {
setStatus(TYPE.CHOOSE); setStatus(TYPE.CHOOSE);
setSubtitle(I18n.t('Passcode_choose_error')); setSubtitle(I18n.t('Passcode_choose_error'));
confirmRef?.current?.animate('shake'); chooseRef?.current?.animate('shake');
chooseRef?.current?.clearPasscode();
Haptics.notificationAsync(Haptics.NotificationFeedbackType.Error); Haptics.notificationAsync(Haptics.NotificationFeedbackType.Error);
}, 200);
}; };
if (status === TYPE.CONFIRM) { if (status === TYPE.CONFIRM) {
@ -42,6 +49,7 @@ const PasscodeEnter = ({ theme, finishProcess }) => {
return ( return (
<Base <Base
ref={chooseRef}
theme={theme} theme={theme}
type={TYPE.CHOOSE} type={TYPE.CHOOSE}
onEndProcess={firstStep} onEndProcess={firstStep}