Skip to content
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
52 changes: 0 additions & 52 deletions src/components/withToggleVisibilityView.js

This file was deleted.

30 changes: 30 additions & 0 deletions src/components/withToggleVisibilityView.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React, {ComponentType, ForwardedRef, ReactElement, RefAttributes} from 'react';
import {View} from 'react-native';
import {SetOptional} from 'type-fest';
import getComponentDisplayName from '@libs/getComponentDisplayName';
import styles from '@styles/styles';

type ToggleVisibilityViewProps = {
/** Whether the content is visible. */
isVisible: boolean;
};

export default function withToggleVisibilityView<TProps extends ToggleVisibilityViewProps, TRef>(
WrappedComponent: ComponentType<TProps & RefAttributes<TRef>>,
): (props: TProps & RefAttributes<TRef>) => ReactElement | null {
function WithToggleVisibilityView({isVisible = false, ...rest}: SetOptional<TProps, 'isVisible'>, ref: ForwardedRef<TRef>) {
return (
<View style={!isVisible && styles.visuallyHidden}>
<WrappedComponent
// eslint-disable-next-line react/jsx-props-no-spreading
{...(rest as TProps)}
ref={ref}
isVisible={isVisible}
/>
</View>
);
}

WithToggleVisibilityView.displayName = `WithToggleVisibilityViewWithRef(${getComponentDisplayName(WrappedComponent)})`;
return React.forwardRef(WithToggleVisibilityView);
}
6 changes: 3 additions & 3 deletions src/pages/signin/LoginForm/BaseLoginForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Text from '@components/Text';
import TextInput from '@components/TextInput';
import withLocalize, {withLocalizePropTypes} from '@components/withLocalize';
import withNavigationFocus from '@components/withNavigationFocus';
import withToggleVisibilityView, {toggleVisibilityViewPropTypes} from '@components/withToggleVisibilityView';
import withToggleVisibilityView from '@components/withToggleVisibilityView';
import withWindowDimensions, {windowDimensionsPropTypes} from '@components/withWindowDimensions';
import usePrevious from '@hooks/usePrevious';
import canFocusInputOnScreenFocus from '@libs/canFocusInputOnScreenFocus';
Expand Down Expand Up @@ -72,14 +72,14 @@ const propTypes = {
/** Whether or not the sign in page is being rendered in the RHP modal */
isInModal: PropTypes.bool,

isVisible: PropTypes.bool.isRequired,

/** Whether navigation is focused */
isFocused: PropTypes.bool.isRequired,

...windowDimensionsPropTypes,

...withLocalizePropTypes,

...toggleVisibilityViewPropTypes,
};

const defaultProps = {
Expand Down