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';
|
||||
|
||||
const Base = forwardRef(({
|
||||
theme, type, onEndProcess, previousPasscode, title, subtitle, onError
|
||||
theme, type, onEndProcess, previousPasscode, title, subtitle, onError, showBiometry, onBiometryPress
|
||||
}, ref) => {
|
||||
const rootRef = useRef();
|
||||
const dotsRef = useRef();
|
||||
|
@ -102,7 +102,13 @@ const Base = forwardRef(({
|
|||
))}
|
||||
</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}>
|
||||
<Button text='0' theme={theme} onPress={onPressNumber} />
|
||||
</Col>
|
||||
|
@ -122,8 +128,10 @@ Base.propTypes = {
|
|||
previousPasscode: PropTypes.string,
|
||||
title: PropTypes.string,
|
||||
subtitle: PropTypes.string,
|
||||
showBiometry: PropTypes.string,
|
||||
onEndProcess: PropTypes.func,
|
||||
onError: PropTypes.func
|
||||
onError: PropTypes.func,
|
||||
onBiometryPress: PropTypes.func
|
||||
};
|
||||
|
||||
export default Base;
|
||||
|
|
|
@ -46,12 +46,12 @@ export default StyleSheet.create({
|
|||
},
|
||||
textTitle: {
|
||||
fontSize: 20,
|
||||
fontWeight: '200',
|
||||
fontWeight: '300',
|
||||
lineHeight: UNIT * 2.5
|
||||
},
|
||||
textSubtitle: {
|
||||
fontSize: UNIT,
|
||||
fontWeight: '200',
|
||||
fontWeight: '300',
|
||||
textAlign: 'center'
|
||||
},
|
||||
flexCirclePasscode: {
|
||||
|
|
|
@ -21,6 +21,7 @@ const PasscodeEnter = ({ theme, finishProcess }) => {
|
|||
let lockedUntil = false;
|
||||
const [passcode, setPasscode] = useState(null);
|
||||
const [status, setStatus] = useState(TYPE.ENTER);
|
||||
const [hasBiometry, setHasBiometry] = useState(false);
|
||||
const { getItem: getAttempts, setItem: setAttempts } = useAsyncStorage(ATTEMPTS_KEY);
|
||||
const { setItem: setLockedUntil } = useAsyncStorage(LOCKED_OUT_TIMER_KEY);
|
||||
|
||||
|
@ -43,6 +44,11 @@ const PasscodeEnter = ({ theme, finishProcess }) => {
|
|||
fetchPasscode();
|
||||
};
|
||||
|
||||
const checkBiometry = async() => {
|
||||
const b = await LocalAuthentication.isEnrolledAsync();
|
||||
setHasBiometry(b);
|
||||
};
|
||||
|
||||
const biometry = async() => {
|
||||
const result = await LocalAuthentication.authenticateAsync({ disableDeviceFallback: true });
|
||||
if (result?.success) {
|
||||
|
@ -52,6 +58,7 @@ const PasscodeEnter = ({ theme, finishProcess }) => {
|
|||
|
||||
useEffect(() => {
|
||||
readStorage();
|
||||
checkBiometry();
|
||||
biometry();
|
||||
}, []);
|
||||
|
||||
|
@ -74,7 +81,17 @@ const PasscodeEnter = ({ theme, finishProcess }) => {
|
|||
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 = {
|
||||
|
|
Loading…
Reference in New Issue