import PropTypes from 'prop-types'; import React, { useContext } from 'react'; import withModalProps from '../../../../helpers/higher-order-components/with-modal-props'; import Box from '../../../ui/box'; import { Button, BUTTON_SIZES, BUTTON_VARIANT, ButtonIcon, IconName, Text, } from '../../../component-library'; import { AlignItems, Display, FlexDirection, JustifyContent, Size, TextVariant, } from '../../../../helpers/constants/design-system'; import HoldToRevealButton from '../../hold-to-reveal-button'; import { useI18nContext } from '../../../../hooks/useI18nContext'; import ZENDESK_URLS from '../../../../helpers/constants/zendesk-url'; import { MetaMetricsContext } from '../../../../contexts/metametrics'; import { MetaMetricsEventCategory, MetaMetricsEventKeyType, MetaMetricsEventName, } from '../../../../../shared/constants/metametrics'; const HoldToRevealModal = ({ onLongPressed, hideModal, willHide = true, holdToRevealType = 'SRP', }) => { const t = useI18nContext(); const holdToRevealTitle = holdToRevealType === 'SRP' ? 'holdToRevealSRPTitle' : 'holdToRevealPrivateKeyTitle'; const holdToRevealButton = holdToRevealType === 'SRP' ? 'holdToRevealSRP' : 'holdToRevealPrivateKey'; const trackEvent = useContext(MetaMetricsContext); const unlock = () => { onLongPressed(); if (willHide) { hideModal(); } }; const handleCancel = () => { hideModal(); }; const renderHoldToRevealPrivateKeyContent = () => { return ( {t('holdToRevealContentPrivateKey1', [ {t('holdToRevealContentPrivateKey2')} , ])} {t('holdToRevealContent3', [ {t('holdToRevealContent4')} , , ])} ); }; const renderHoldToRevealSRPContent = () => { return ( {t('holdToRevealContent1', [ {t('holdToRevealContent2')} , ])} {t('holdToRevealContent3', [ {t('holdToRevealContent4')} , , ])} ); }; return ( {t(holdToRevealTitle)} {willHide && ( { trackEvent({ category: MetaMetricsEventCategory.Keys, event: MetaMetricsEventName.SrpHoldToRevealCloseClicked, properties: { key_type: MetaMetricsEventKeyType.Srp, }, }); handleCancel(); }} ariaLabel={t('close')} /> )} {holdToRevealType === 'SRP' ? renderHoldToRevealSRPContent() : renderHoldToRevealPrivateKeyContent()} ); }; HoldToRevealModal.propTypes = { // The function to be executed after the hold to reveal long press has been completed onLongPressed: PropTypes.func.isRequired, hideModal: PropTypes.func, willHide: PropTypes.bool, holdToRevealType: PropTypes.oneOf(['SRP', 'PrivateKey']).isRequired, }; export default withModalProps(HoldToRevealModal);