Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

20601 — migrate PressableWithDelayToggle #20658

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/CopyTextToClipboard.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, {useCallback} from 'react';
import PropTypes from 'prop-types';
import * as Expensicons from './Icon/Expensicons';
import PressableWithDelayToggle from './PressableWithDelayToggle';
import PressableWithDelayToggle from './Pressable/PressableWithDelayToggle';
import Clipboard from '../libs/Clipboard';
import withLocalize, {withLocalizePropTypes} from './withLocalize';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import React from 'react';
import PropTypes from 'prop-types';
import {Pressable} from 'react-native';
import * as Expensicons from './Icon/Expensicons';
import compose from '../libs/compose';
import Icon from './Icon';
import Tooltip from './Tooltip';
import Text from './Text';
import styles from '../styles/styles';
import variables from '../styles/variables';
import getButtonState from '../libs/getButtonState';
import * as StyleUtils from '../styles/StyleUtils';
import withLocalize, {withLocalizePropTypes} from './withLocalize';
import withDelayToggleButtonState, {withDelayToggleButtonStatePropTypes} from './withDelayToggleButtonState';
import * as Expensicons from '../Icon/Expensicons';
import compose from '../../libs/compose';
import Icon from '../Icon';
import Tooltip from '../Tooltip';
import Text from '../Text';
import styles from '../../styles/styles';
import variables from '../../styles/variables';
import getButtonState from '../../libs/getButtonState';
import * as StyleUtils from '../../styles/StyleUtils';
import withLocalize, {withLocalizePropTypes} from '../withLocalize';
import withDelayToggleButtonState, {withDelayToggleButtonStatePropTypes} from '../withDelayToggleButtonState';
import PressableWithoutFeedback from './PressableWithoutFeedback';

const propTypes = {
...withLocalizePropTypes,
Expand Down Expand Up @@ -84,16 +84,19 @@ function PressableWithDelayToggle(props) {
// Due to limitations in RN regarding the vertical text alignment of non-Text elements,
// for elements that are supposed to be inline, we need to use a Text element instead
// of a Pressable
const PressableView = props.inline ? Text : Pressable;
const PressableView = props.inline ? Text : PressableWithoutFeedback;
const tooltipText = props.isDelayButtonStateComplete ? props.tooltipTextChecked : props.tooltipText;

return (
<PressableView
ref={props.innerRef}
style={[styles.flexRow, ...props.styles]}
onPress={updatePressState}
accessibilityLabel={tooltipText}
>
<Tooltip
containerStyles={[styles.flexRow]}
text={props.isDelayButtonStateComplete ? props.tooltipTextChecked : props.tooltipText}
text={tooltipText}
>
<>
<Text
Expand All @@ -103,10 +106,9 @@ function PressableWithDelayToggle(props) {
{props.isDelayButtonStateComplete && props.textChecked ? props.textChecked : props.text}
&nbsp;
</Text>
<Pressable
ref={props.innerRef}
focusable
accessibilityLabel={props.isDelayButtonStateComplete ? props.tooltipTextChecked : props.tooltipText}
<PressableWithoutFeedback
focusable={false}
accessible={false}
onPress={updatePressState}
>
{({hovered, pressed}) => (
Expand All @@ -122,7 +124,7 @@ function PressableWithDelayToggle(props) {
)}
</>
)}
</Pressable>
</PressableWithoutFeedback>
</>
</Tooltip>
</PressableView>
Expand Down
1 change: 1 addition & 0 deletions src/components/Pressable/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export {default as GenericPressable} from './GenericPressable';
export {default as PressableWithFeedback} from './PressableWithFeedback';
export {default as PressableWithoutFeedback} from './PressableWithoutFeedback';
export {default as PressableWithDelayToggle} from './PressableWithDelayToggle';
2 changes: 1 addition & 1 deletion src/pages/settings/Security/TwoFactorAuth/CodesPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import withWindowDimensions, {windowDimensionsPropTypes} from '../../../../compo
import styles from '../../../../styles/styles';
import FixedFooter from '../../../../components/FixedFooter';
import Button from '../../../../components/Button';
import PressableWithDelayToggle from '../../../../components/PressableWithDelayToggle';
import PressableWithDelayToggle from '../../../../components/Pressable/PressableWithDelayToggle';
import Text from '../../../../components/Text';
import Section from '../../../../components/Section';
import ONYXKEYS from '../../../../ONYXKEYS';
Expand Down
2 changes: 1 addition & 1 deletion src/pages/settings/Security/TwoFactorAuth/VerifyPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import TextLink from '../../../../components/TextLink';
import Clipboard from '../../../../libs/Clipboard';
import FixedFooter from '../../../../components/FixedFooter';
import * as Expensicons from '../../../../components/Icon/Expensicons';
import PressableWithDelayToggle from '../../../../components/PressableWithDelayToggle';
import PressableWithDelayToggle from '../../../../components/Pressable/PressableWithDelayToggle';
import TwoFactorAuthForm from './TwoFactorAuthForm';
import QRCode from '../../../../components/QRCode';
import expensifyLogo from '../../../../../assets/images/expensify-logo-round-transparent.png';
Expand Down