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; previousPasscode?: string;
title: string; title: string;
subtitle?: string; subtitle?: string;
showBiometry?: string; showBiometry?: boolean;
onEndProcess: Function; onEndProcess: Function;
onError?: Function; onError?: Function;
onBiometryPress?(): void; onBiometryPress?(): void;

View File

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

View File

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