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

Fix: App changes positions of Ui elements when phone language RTL #7594

Merged
merged 26 commits into from
Feb 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
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
1 change: 1 addition & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
</queries>

<application
android:supportsRtl="false"
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
Expand Down
41 changes: 41 additions & 0 deletions src/components/RNTextInput.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import React from 'react';
import _ from 'underscore';
// eslint-disable-next-line no-restricted-imports
import {TextInput} from 'react-native';
import PropTypes from 'prop-types';

const propTypes = {
/** A ref to forward to the text input */
forwardedRef: PropTypes.func,
};

const defaultProps = {
forwardedRef: () => {},
};

const RNTextInput = props => (
<TextInput
ref={(ref) => {
if (!_.isFunction(props.forwardedRef)) {
return;
}
props.forwardedRef(ref);
}}

// By default, align input to the left to override right alignment in RTL mode which is not yet supported in the App.
// eslint-disable-next-line react/jsx-props-no-multi-spaces
textAlign="left"

// eslint-disable-next-line
{...props}
/>
);

RNTextInput.propTypes = propTypes;
RNTextInput.defaultProps = defaultProps;
RNTextInput.displayName = 'RNTextInput';

export default React.forwardRef((props, ref) => (
/* eslint-disable-next-line react/jsx-props-no-spreading */
<RNTextInput {...props} forwardedRef={ref} />
));
5 changes: 2 additions & 3 deletions src/components/Text.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ const propTypes = {
fontSize: PropTypes.number,

/** The alignment of the text */
// eslint-disable-next-line react/forbid-prop-types
textAlign: PropTypes.any,
textAlign: PropTypes.string,

/** Any children to display */
children: PropTypes.node,
Expand All @@ -32,7 +31,7 @@ const defaultProps = {
color: themeColors.text,
fontSize: variables.fontSizeNormal,
family: 'GTA',
textAlign: null,
textAlign: 'left',
ahmdshrif marked this conversation as resolved.
Show resolved Hide resolved
children: null,
style: {},
};
Expand Down
3 changes: 1 addition & 2 deletions src/components/TextInput/BaseTextInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import _ from 'underscore';
import React, {Component} from 'react';
import {
Animated, View, TouchableWithoutFeedback, Pressable, AppState, Keyboard,
// eslint-disable-next-line no-restricted-imports
TextInput as RNTextInput,
} from 'react-native';
import Str from 'expensify-common/lib/str';
import RNTextInput from '../RNTextInput';
import TextInputLabel from './TextInputLabel';
import * as baseTextInputPropTypes from './baseTextInputPropTypes';
import themeColors from '../../styles/themes/default';
Expand Down
5 changes: 2 additions & 3 deletions src/components/TextInputFocusable/index.android.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React from 'react';
// eslint-disable-next-line no-restricted-imports
import {TextInput} from 'react-native';
import PropTypes from 'prop-types';
import _ from 'underscore';
import RNTextInput from '../RNTextInput';
import themeColors from '../../styles/themes/default';
import CONST from '../../CONST';

Expand Down Expand Up @@ -64,7 +63,7 @@ class TextInputFocusable extends React.Component {

render() {
return (
<TextInput
<RNTextInput
placeholderTextColor={themeColors.placeholderText}
ref={el => this.textInput = el}
maxHeight={CONST.COMPOSER_MAX_HEIGHT}
Expand Down
5 changes: 2 additions & 3 deletions src/components/TextInputFocusable/index.ios.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React from 'react';
// eslint-disable-next-line no-restricted-imports
import {TextInput} from 'react-native';
import PropTypes from 'prop-types';
import _ from 'underscore';
import RNTextInput from '../RNTextInput';
import themeColors from '../../styles/themes/default';
import CONST from '../../CONST';

Expand Down Expand Up @@ -76,7 +75,7 @@ class TextInputFocusable extends React.Component {
// Selection Property not worked in IOS properly, So removed from props.
const propsToPass = _.omit(this.props, 'selection');
return (
<TextInput
<RNTextInput
placeholderTextColor={themeColors.placeholderText}
ref={el => this.textInput = el}
maxHeight={CONST.COMPOSER_MAX_HEIGHT}
Expand Down
6 changes: 3 additions & 3 deletions src/components/TextInputFocusable/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';
// eslint-disable-next-line no-restricted-imports
import {TextInput, StyleSheet} from 'react-native';
import {StyleSheet} from 'react-native';
import PropTypes from 'prop-types';
import _ from 'underscore';
import ExpensiMark from 'expensify-common/lib/ExpensiMark';
import RNTextInput from '../RNTextInput';
import withLocalize, {withLocalizePropTypes} from '../withLocalize';
import Growl from '../../libs/Growl';
import themeColors from '../../styles/themes/default';
Expand Down Expand Up @@ -348,7 +348,7 @@ class TextInputFocusable extends React.Component {
propStyles.outline = 'none';
const propsWithoutStyles = _.omit(this.props, 'style');
return (
<TextInput
<RNTextInput
placeholderTextColor={themeColors.placeholderText}
ref={el => this.textInput = el}
selection={this.state.selection}
Expand Down
6 changes: 3 additions & 3 deletions src/components/TextInputWithPrefix/index.android.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import PropTypes from 'prop-types';
// eslint-disable-next-line no-restricted-imports
import {TextInput, View} from 'react-native';
import {View} from 'react-native';
import _ from 'underscore';
import React from 'react';
import RNTextInput from '../RNTextInput';
import Text from '../Text';
import styles from '../../styles/styles';
import InlineErrorText from '../InlineErrorText';
Expand Down Expand Up @@ -35,7 +35,7 @@ const TextInputWithPrefix = props => (
]}
>
<Text style={[styles.textInputWithPrefix.prefix, {paddingTop: 10}]}>{props.prefixCharacter}</Text>
<TextInput
<RNTextInput
style={[
styles.textInputWithPrefix.textInput,
styles.noOutline,
Expand Down
6 changes: 3 additions & 3 deletions src/components/TextInputWithPrefix/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import PropTypes from 'prop-types';
// eslint-disable-next-line no-restricted-imports
import {TextInput, View} from 'react-native';
import {View} from 'react-native';
import _ from 'underscore';
import React from 'react';
import RNTextInput from '../RNTextInput';
import Text from '../Text';
import styles from '../../styles/styles';
import InlineErrorText from '../InlineErrorText';
Expand Down Expand Up @@ -34,7 +34,7 @@ const TextInputWithPrefix = props => (
]}
>
<Text style={styles.textInputWithPrefix.prefix}>{props.prefixCharacter}</Text>
<TextInput
<RNTextInput
style={[
styles.textInputWithPrefix.textInput,
styles.noOutline,
Expand Down
6 changes: 6 additions & 0 deletions src/setup/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {I18nManager} from 'react-native';
import Onyx from 'react-native-onyx';
import ONYXKEYS from '../ONYXKEYS';
import CONST from '../CONST';
Expand Down Expand Up @@ -35,6 +36,11 @@ export default function () {
},
});

// Force app layout to work left to right because our design does not currently support devices using this mode
I18nManager.allowRTL(false);
I18nManager.forceRTL(false);
I18nManager.swapLeftAndRightInRTL(false);

// Perform any other platform-specific setup
platformSetup();
}
2 changes: 2 additions & 0 deletions src/styles/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const picker = {
borderStyle: 'solid',
borderColor: themeColors.border,
borderRadius: variables.componentBorderRadiusNormal,
textAlign: 'left',
};

const link = {
Expand Down Expand Up @@ -656,6 +657,7 @@ const styles = {
color: themeColors.textSupporting,
fontFamily: fontFamily.GTA,
width: '100%',
textAlign: 'left',
},

textInputLabelBackground: {
Expand Down