Chore: Migrate ScreenLockedView to Typescript (#3515)

This commit is contained in:
Reinaldo Neto 2021-12-02 10:26:02 -03:00 committed by GitHub
parent 79feef179c
commit 8d06b17995
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 13 deletions

View File

@ -20,7 +20,7 @@ interface IPasscodeBase {
previousPasscode?: string;
title: string;
subtitle?: string;
showBiometry?: string;
showBiometry?: boolean;
onEndProcess: Function;
onError?: Function;
onBiometryPress?(): void;

View File

@ -15,7 +15,7 @@ import I18n from '../../i18n';
interface IPasscodePasscodeEnter {
theme: string;
hasBiometry: string;
hasBiometry: boolean;
finishProcess: Function;
}

View File

@ -1,19 +1,25 @@
import React, { useEffect, useState } from 'react';
import PropTypes from 'prop-types';
import Modal from 'react-native-modal';
import useDeepCompareEffect from 'use-deep-compare-effect';
import isEmpty from 'lodash/isEmpty';
import Orientation from 'react-native-orientation-locker';
import { withTheme } from '../theme';
import { useTheme } from '../theme';
import EventEmitter from '../utils/events';
import { LOCAL_AUTHENTICATE_EMITTER } from '../constants/localAuthentication';
import { isTablet } from '../utils/deviceInfo';
import { PasscodeEnter } from '../containers/Passcode';
const ScreenLockedView = ({ theme }) => {
interface IData {
submit?: () => void;
hasBiometry?: boolean;
}
const ScreenLockedView = (): JSX.Element => {
const [visible, setVisible] = useState(false);
const [data, setData] = useState({});
const [data, setData] = useState<IData>({});
const { theme } = useTheme();
useDeepCompareEffect(() => {
if (!isEmpty(data)) {
@ -23,7 +29,7 @@ const ScreenLockedView = ({ theme }) => {
}
}, [data]);
const showScreenLock = args => {
const showScreenLock = (args: IData) => {
setData(args);
};
@ -56,13 +62,9 @@ const ScreenLockedView = ({ theme }) => {
style={{ margin: 0 }}
animationIn='fadeIn'
animationOut='fadeOut'>
<PasscodeEnter theme={theme} hasBiometry={data?.hasBiometry} finishProcess={onSubmit} />
<PasscodeEnter theme={theme} hasBiometry={!!data?.hasBiometry} finishProcess={onSubmit} />
</Modal>
);
};
ScreenLockedView.propTypes = {
theme: PropTypes.string
};
export default withTheme(ScreenLockedView);
export default ScreenLockedView;