Biometry button on PasscodeEnter
This commit is contained in:
parent
b1a48daca4
commit
47a5909653
|
@ -16,7 +16,7 @@ import { themes } from '../../../constants/colors';
|
||||||
import { PASSCODE_LENGTH } from '../../../constants/localAuthentication';
|
import { PASSCODE_LENGTH } from '../../../constants/localAuthentication';
|
||||||
|
|
||||||
const Base = forwardRef(({
|
const Base = forwardRef(({
|
||||||
theme, type, onEndProcess, previousPasscode, title, subtitle, onError
|
theme, type, onEndProcess, previousPasscode, title, subtitle, onError, showBiometry, onBiometryPress
|
||||||
}, ref) => {
|
}, ref) => {
|
||||||
const rootRef = useRef();
|
const rootRef = useRef();
|
||||||
const dotsRef = useRef();
|
const dotsRef = useRef();
|
||||||
|
@ -102,7 +102,13 @@ const Base = forwardRef(({
|
||||||
))}
|
))}
|
||||||
</Row>
|
</Row>
|
||||||
<Row style={styles.row}>
|
<Row style={styles.row}>
|
||||||
<Col style={styles.colButtonCircle} />
|
{showBiometry
|
||||||
|
? (
|
||||||
|
<Col style={styles.colButtonCircle}>
|
||||||
|
<Button text='B' theme={theme} onPress={onBiometryPress} />
|
||||||
|
</Col>
|
||||||
|
)
|
||||||
|
: <Col style={styles.colButtonCircle} />}
|
||||||
<Col style={styles.colButtonCircle}>
|
<Col style={styles.colButtonCircle}>
|
||||||
<Button text='0' theme={theme} onPress={onPressNumber} />
|
<Button text='0' theme={theme} onPress={onPressNumber} />
|
||||||
</Col>
|
</Col>
|
||||||
|
@ -122,8 +128,10 @@ Base.propTypes = {
|
||||||
previousPasscode: PropTypes.string,
|
previousPasscode: PropTypes.string,
|
||||||
title: PropTypes.string,
|
title: PropTypes.string,
|
||||||
subtitle: PropTypes.string,
|
subtitle: PropTypes.string,
|
||||||
|
showBiometry: PropTypes.string,
|
||||||
onEndProcess: PropTypes.func,
|
onEndProcess: PropTypes.func,
|
||||||
onError: PropTypes.func
|
onError: PropTypes.func,
|
||||||
|
onBiometryPress: PropTypes.func
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Base;
|
export default Base;
|
||||||
|
|
|
@ -46,12 +46,12 @@ export default StyleSheet.create({
|
||||||
},
|
},
|
||||||
textTitle: {
|
textTitle: {
|
||||||
fontSize: 20,
|
fontSize: 20,
|
||||||
fontWeight: '200',
|
fontWeight: '300',
|
||||||
lineHeight: UNIT * 2.5
|
lineHeight: UNIT * 2.5
|
||||||
},
|
},
|
||||||
textSubtitle: {
|
textSubtitle: {
|
||||||
fontSize: UNIT,
|
fontSize: UNIT,
|
||||||
fontWeight: '200',
|
fontWeight: '300',
|
||||||
textAlign: 'center'
|
textAlign: 'center'
|
||||||
},
|
},
|
||||||
flexCirclePasscode: {
|
flexCirclePasscode: {
|
||||||
|
|
|
@ -21,6 +21,7 @@ const PasscodeEnter = ({ theme, finishProcess }) => {
|
||||||
let lockedUntil = false;
|
let lockedUntil = false;
|
||||||
const [passcode, setPasscode] = useState(null);
|
const [passcode, setPasscode] = useState(null);
|
||||||
const [status, setStatus] = useState(TYPE.ENTER);
|
const [status, setStatus] = useState(TYPE.ENTER);
|
||||||
|
const [hasBiometry, setHasBiometry] = useState(false);
|
||||||
const { getItem: getAttempts, setItem: setAttempts } = useAsyncStorage(ATTEMPTS_KEY);
|
const { getItem: getAttempts, setItem: setAttempts } = useAsyncStorage(ATTEMPTS_KEY);
|
||||||
const { setItem: setLockedUntil } = useAsyncStorage(LOCKED_OUT_TIMER_KEY);
|
const { setItem: setLockedUntil } = useAsyncStorage(LOCKED_OUT_TIMER_KEY);
|
||||||
|
|
||||||
|
@ -43,6 +44,11 @@ const PasscodeEnter = ({ theme, finishProcess }) => {
|
||||||
fetchPasscode();
|
fetchPasscode();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const checkBiometry = async() => {
|
||||||
|
const b = await LocalAuthentication.isEnrolledAsync();
|
||||||
|
setHasBiometry(b);
|
||||||
|
};
|
||||||
|
|
||||||
const biometry = async() => {
|
const biometry = async() => {
|
||||||
const result = await LocalAuthentication.authenticateAsync({ disableDeviceFallback: true });
|
const result = await LocalAuthentication.authenticateAsync({ disableDeviceFallback: true });
|
||||||
if (result?.success) {
|
if (result?.success) {
|
||||||
|
@ -52,6 +58,7 @@ const PasscodeEnter = ({ theme, finishProcess }) => {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
readStorage();
|
readStorage();
|
||||||
|
checkBiometry();
|
||||||
biometry();
|
biometry();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
@ -74,7 +81,17 @@ const PasscodeEnter = ({ theme, finishProcess }) => {
|
||||||
return <Locked theme={theme} setStatus={setStatus} />;
|
return <Locked theme={theme} setStatus={setStatus} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
return <Base ref={ref} theme={theme} type={TYPE.ENTER} onEndProcess={onEndProcess} title={I18n.t('Passcode_enter_title')} />;
|
return (
|
||||||
|
<Base
|
||||||
|
ref={ref}
|
||||||
|
theme={theme}
|
||||||
|
type={TYPE.ENTER}
|
||||||
|
title={I18n.t('Passcode_enter_title')}
|
||||||
|
showBiometry={hasBiometry}
|
||||||
|
onEndProcess={onEndProcess}
|
||||||
|
onBiometryPress={biometry}
|
||||||
|
/>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
PasscodeEnter.propTypes = {
|
PasscodeEnter.propTypes = {
|
||||||
|
|
Loading…
Reference in New Issue