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

[NoQA] Separate autofill logic between platforms #15295

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
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
import React from 'react';
import {
Platform,
TouchableOpacity, View,
} from 'react-native';
import PropTypes from 'prop-types';
import {withOnyx} from 'react-native-onyx';
import _ from 'underscore';
import styles from '../../styles/styles';
import Button from '../../components/Button';
import Text from '../../components/Text';
import themeColors from '../../styles/themes/default';
import * as Session from '../../libs/actions/Session';
import ONYXKEYS from '../../ONYXKEYS';
import CONST from '../../CONST';
import ChangeExpensifyLoginLink from './ChangeExpensifyLoginLink';
import withLocalize, {withLocalizePropTypes} from '../../components/withLocalize';
import compose from '../../libs/compose';
import TextInput from '../../components/TextInput';
import * as ValidationUtils from '../../libs/ValidationUtils';
import withToggleVisibilityView, {toggleVisibilityViewPropTypes} from '../../components/withToggleVisibilityView';
import canFocusInputOnScreenFocus from '../../libs/canFocusInputOnScreenFocus';
import * as ErrorUtils from '../../libs/ErrorUtils';
import {withNetwork} from '../../components/OnyxProvider';
import networkPropTypes from '../../components/networkPropTypes';
import OfflineIndicator from '../../components/OfflineIndicator';
import * as User from '../../libs/actions/User';
import FormHelpMessage from '../../components/FormHelpMessage';
import styles from '../../../styles/styles';
import Button from '../../../components/Button';
import Text from '../../../components/Text';
import themeColors from '../../../styles/themes/default';
import * as Session from '../../../libs/actions/Session';
import ONYXKEYS from '../../../ONYXKEYS';
import CONST from '../../../CONST';
import ChangeExpensifyLoginLink from '../ChangeExpensifyLoginLink';
import withLocalize, {withLocalizePropTypes} from '../../../components/withLocalize';
import compose from '../../../libs/compose';
import TextInput from '../../../components/TextInput';
import * as ValidationUtils from '../../../libs/ValidationUtils';
import withToggleVisibilityView, {toggleVisibilityViewPropTypes} from '../../../components/withToggleVisibilityView';
import canFocusInputOnScreenFocus from '../../../libs/canFocusInputOnScreenFocus';
import * as ErrorUtils from '../../../libs/ErrorUtils';
import {withNetwork} from '../../../components/OnyxProvider';
import networkPropTypes from '../../../components/networkPropTypes';
import OfflineIndicator from '../../../components/OfflineIndicator';
import * as User from '../../../libs/actions/User';
import FormHelpMessage from '../../../components/FormHelpMessage';

const propTypes = {
/* Onyx Props */
Expand All @@ -48,6 +47,9 @@ const propTypes = {
/** Information about the network */
network: networkPropTypes.isRequired,

/** Specifies autocomplete hints for the system, so it can provide autofill */
autoComplete: PropTypes.oneOf(['sms-otp', 'one-time-code']).isRequired,

...withLocalizePropTypes,
...toggleVisibilityViewPropTypes,
};
Expand All @@ -57,7 +59,7 @@ const defaultProps = {
credentials: {},
};

class ValidateCodeForm extends React.Component {
class BaseValidateCodeForm extends React.Component {
constructor(props) {
super(props);
this.validateAndSubmitForm = this.validateAndSubmitForm.bind(this);
Expand Down Expand Up @@ -195,7 +197,7 @@ class ValidateCodeForm extends React.Component {
) : (
<View style={[styles.mv3]}>
<TextInput
autoComplete={Platform.select({android: 'sms-otp', web: 'one-time-code', ios: 'one-time-code'})}
autoComplete={this.props.autoComplete}
narefyev91 marked this conversation as resolved.
Show resolved Hide resolved
textContentType="oneTimeCode"
ref={el => this.inputValidateCode = el}
label={this.props.translate('common.magicCode')}
Expand Down Expand Up @@ -243,8 +245,8 @@ class ValidateCodeForm extends React.Component {
}
}

ValidateCodeForm.propTypes = propTypes;
ValidateCodeForm.defaultProps = defaultProps;
BaseValidateCodeForm.propTypes = propTypes;
BaseValidateCodeForm.defaultProps = defaultProps;

export default compose(
withLocalize,
Expand All @@ -254,4 +256,4 @@ export default compose(
}),
withToggleVisibilityView,
withNetwork(),
)(ValidateCodeForm);
)(BaseValidateCodeForm);
20 changes: 20 additions & 0 deletions src/pages/signin/ValidateCodeForm/index.android.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from 'react';
import PropTypes from 'prop-types';
import BaseValidateCodeForm from './BaseValidateCodeForm';

const defaultProps = {
isVisible: false,
};

const propTypes = {
isVisible: PropTypes.bool,
};
const ValidateCodeForm = props => (
<BaseValidateCodeForm isVisible={props.isVisible} autoComplete="sms-otp" />
);

ValidateCodeForm.displayName = 'ValidateCodeForm';
ValidateCodeForm.propTypes = propTypes;
ValidateCodeForm.defaultProps = defaultProps;

export default ValidateCodeForm;
20 changes: 20 additions & 0 deletions src/pages/signin/ValidateCodeForm/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from 'react';
import PropTypes from 'prop-types';
import BaseValidateCodeForm from './BaseValidateCodeForm';

const defaultProps = {
isVisible: false,
};

const propTypes = {
isVisible: PropTypes.bool,
};
const ValidateCodeForm = props => (
<BaseValidateCodeForm isVisible={props.isVisible} autoComplete="one-time-code" />
);

ValidateCodeForm.displayName = 'ValidateCodeForm';
ValidateCodeForm.propTypes = propTypes;
ValidateCodeForm.defaultProps = defaultProps;

export default ValidateCodeForm;