From 85e8698c48170b9041cacd038e0432b788a68778 Mon Sep 17 00:00:00 2001 From: Tim Golen Date: Thu, 19 May 2022 08:58:53 -0600 Subject: [PATCH 1/8] Restructure the typing indicator a little better --- src/pages/home/report/ReportActionCompose.js | 6 ++++-- src/pages/home/report/ReportTypingIndicator.js | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/pages/home/report/ReportActionCompose.js b/src/pages/home/report/ReportActionCompose.js index a3f2c17ab409..73043f9b85ed 100755 --- a/src/pages/home/report/ReportActionCompose.js +++ b/src/pages/home/report/ReportActionCompose.js @@ -591,7 +591,7 @@ class ReportActionCompose extends React.Component { - {this.props.network.isOffline ? ( + {this.props.network.isOffline && ( - ) : } + )} + + {hasExceededMaxCommentLength && ( diff --git a/src/pages/home/report/ReportTypingIndicator.js b/src/pages/home/report/ReportTypingIndicator.js index ee43a3a004ff..8c2e95974ecd 100755 --- a/src/pages/home/report/ReportTypingIndicator.js +++ b/src/pages/home/report/ReportTypingIndicator.js @@ -49,7 +49,8 @@ class ReportTypingIndicator extends React.Component { // Decide on the Text element that will hold the display based on the number of users that are typing. switch (numUsersTyping) { case 0: - return <>; + return null; + case 1: return ( ); + default: return ( Date: Thu, 19 May 2022 09:06:05 -0600 Subject: [PATCH 2/8] Add new component for appearing to be offline --- src/components/YouAppearToBeOffline.js | 43 ++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/components/YouAppearToBeOffline.js diff --git a/src/components/YouAppearToBeOffline.js b/src/components/YouAppearToBeOffline.js new file mode 100644 index 000000000000..5de5a5948b6c --- /dev/null +++ b/src/components/YouAppearToBeOffline.js @@ -0,0 +1,43 @@ +import React from 'react'; +import {withNetwork} from './OnyxProvider'; +import networkPropTypes from './networkPropTypes'; +import Icon from './Icon'; +import * as Expensicons from './Icon/Expensicons'; +import variables from '../styles/variables'; +import Text from './Text'; +import styles from '../styles/styles'; +import compose from '../libs/compose'; +import withLocalize, {withLocalizePropTypes} from './withLocalize'; + +const propTypes = { + /** Information about the network */ + network: networkPropTypes.isRequired, + + ...withLocalizePropTypes, +}; + +const YouAppearToBeOffline = (props) => { + if (!props.network.isOffline) { + return null; + } + return ( + <> + + + {props.translate('reportActionCompose.youAppearToBeOffline')} + + + ); +}; + +YouAppearToBeOffline.propTypes = propTypes; +YouAppearToBeOffline.displayName = 'YouAppearToBeOffline'; + +export default compose( + withLocalize, + withNetwork(), +)(YouAppearToBeOffline); From 6aa89a000888ac1075ced1fdd518dc7309286911 Mon Sep 17 00:00:00 2001 From: Tim Golen Date: Thu, 19 May 2022 09:24:43 -0600 Subject: [PATCH 3/8] Add new component for exceeding comment length --- src/components/ExceededCommentLength.js | 28 +++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/components/ExceededCommentLength.js diff --git a/src/components/ExceededCommentLength.js b/src/components/ExceededCommentLength.js new file mode 100644 index 000000000000..5b320deba711 --- /dev/null +++ b/src/components/ExceededCommentLength.js @@ -0,0 +1,28 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import CONST from '../CONST'; +import Text from './Text'; +import styles from '../styles/styles'; + +const propTypes = { + /** The current length of the comment */ + commentLength: PropTypes.number.isRequired, +}; + +const ExceededCommentLength = (props) => { + const hasExceededMaxCommentLength = props.commentLength > CONST.MAX_COMMENT_LENGTH; + if (!hasExceededMaxCommentLength) { + return null; + } + + return ( + + {`${props.commentLength}/${CONST.MAX_COMMENT_LENGTH}`} + + ); +}; + +ExceededCommentLength.propTypes = propTypes; +ExceededCommentLength.displayName = 'ExceededCommentLength'; + +export default ExceededCommentLength; From 67825d9e08a8cdd7f004db8b053714fc3ccfa652 Mon Sep 17 00:00:00 2001 From: Tim Golen Date: Thu, 19 May 2022 09:50:45 -0600 Subject: [PATCH 4/8] Move layout styles to the parent --- src/components/YouAppearToBeOffline.js | 7 ++- src/pages/home/report/ParticipantLocalTime.js | 32 ++++------ src/pages/home/report/ReportActionCompose.js | 63 ++++++++----------- .../home/report/ReportTypingIndicator.js | 7 +-- src/styles/styles.js | 2 +- 5 files changed, 43 insertions(+), 68 deletions(-) diff --git a/src/components/YouAppearToBeOffline.js b/src/components/YouAppearToBeOffline.js index 5de5a5948b6c..70cc784100bf 100644 --- a/src/components/YouAppearToBeOffline.js +++ b/src/components/YouAppearToBeOffline.js @@ -1,4 +1,5 @@ import React from 'react'; +import {View} from 'react-native'; import {withNetwork} from './OnyxProvider'; import networkPropTypes from './networkPropTypes'; import Icon from './Icon'; @@ -18,10 +19,10 @@ const propTypes = { const YouAppearToBeOffline = (props) => { if (!props.network.isOffline) { - return null; + //return null; } return ( - <> + { {props.translate('reportActionCompose.youAppearToBeOffline')} - + ); }; diff --git a/src/pages/home/report/ParticipantLocalTime.js b/src/pages/home/report/ParticipantLocalTime.js index 25a14689bf9a..671749d690b0 100644 --- a/src/pages/home/report/ParticipantLocalTime.js +++ b/src/pages/home/report/ParticipantLocalTime.js @@ -1,7 +1,4 @@ import React, {PureComponent} from 'react'; -import { - View, -} from 'react-native'; import lodashGet from 'lodash/get'; import Str from 'expensify-common/lib/str'; import styles from '../../../styles/styles'; @@ -60,23 +57,18 @@ class ParticipantLocalTime extends PureComponent { : this.props.participant.displayName); return ( - - - {this.props.translate( - 'reportActionCompose.localTime', - { - user: reportRecipientDisplayName, - time: this.state.localTime, - }, - )} - - + + {this.props.translate( + 'reportActionCompose.localTime', + { + user: reportRecipientDisplayName, + time: this.state.localTime, + }, + )} + ); } } diff --git a/src/pages/home/report/ReportActionCompose.js b/src/pages/home/report/ReportActionCompose.js index 73043f9b85ed..e9e86f280c3b 100755 --- a/src/pages/home/report/ReportActionCompose.js +++ b/src/pages/home/report/ReportActionCompose.js @@ -26,7 +26,6 @@ import withWindowDimensions, {windowDimensionsPropTypes} from '../../../componen import withDrawerState from '../../../components/withDrawerState'; import CONST from '../../../CONST'; import canFocusInputOnScreenFocus from '../../../libs/canFocusInputOnScreenFocus'; -import variables from '../../../styles/variables'; import withLocalize, {withLocalizePropTypes} from '../../../components/withLocalize'; import Permissions from '../../../libs/Permissions'; import Navigation from '../../../libs/Navigation/Navigation'; @@ -34,17 +33,17 @@ import ROUTES from '../../../ROUTES'; import reportActionPropTypes from './reportActionPropTypes'; import * as ReportUtils from '../../../libs/ReportUtils'; import ReportActionComposeFocusManager from '../../../libs/ReportActionComposeFocusManager'; -import Text from '../../../components/Text'; import participantPropTypes from '../../../components/participantPropTypes'; import ParticipantLocalTime from './ParticipantLocalTime'; -import {withNetwork, withPersonalDetails} from '../../../components/OnyxProvider'; +import {withPersonalDetails} from '../../../components/OnyxProvider'; import DateUtils from '../../../libs/DateUtils'; import * as User from '../../../libs/actions/User'; import Tooltip from '../../../components/Tooltip'; import EmojiPickerButton from '../../../components/EmojiPicker/EmojiPickerButton'; import VirtualKeyboard from '../../../libs/VirtualKeyboard'; import canUseTouchScreen from '../../../libs/canUseTouchscreen'; -import networkPropTypes from '../../../components/networkPropTypes'; +import YouAppearToBeOffline from '../../../components/YouAppearToBeOffline'; +import ExceededCommentLength from '../../../components/ExceededCommentLength'; const propTypes = { /** Beta features list */ @@ -87,9 +86,6 @@ const propTypes = { /** Is composer screen focused */ isFocused: PropTypes.bool.isRequired, - /** Information about the network */ - network: networkPropTypes.isRequired, - // The NVP describing a user's block status blockedFromConcierge: PropTypes.shape({ // The date that the user will be unblocked @@ -447,9 +443,28 @@ class ReportActionCompose extends React.Component { const hasExceededMaxCommentLength = this.comment.length > CONST.MAX_COMMENT_LENGTH; return ( - - {shouldShowReportRecipientLocalTime - && } + + + {shouldShowReportRecipientLocalTime + && ( + + + + )} + + + + + + + + + + + + + + - - - {this.props.network.isOffline && ( - - - - {this.props.translate('reportActionCompose.youAppearToBeOffline')} - - - )} - - - - {hasExceededMaxCommentLength && ( - - {`${this.comment.length}/${CONST.MAX_COMMENT_LENGTH}`} - - )} - ); } @@ -630,7 +618,6 @@ export default compose( withNavigationFocus, withLocalize, withPersonalDetails(), - withNetwork(), withOnyx({ betas: { key: ONYXKEYS.BETAS, diff --git a/src/pages/home/report/ReportTypingIndicator.js b/src/pages/home/report/ReportTypingIndicator.js index 8c2e95974ecd..c7c34ec58db7 100755 --- a/src/pages/home/report/ReportTypingIndicator.js +++ b/src/pages/home/report/ReportTypingIndicator.js @@ -57,18 +57,13 @@ class ReportTypingIndicator extends React.Component { leadingText={PersonalDetails.getDisplayName(this.state.usersTyping[0])} trailingText={` ${this.props.translate('reportTypingIndicator.isTyping')}`} textStyle={[styles.chatItemComposeSecondaryRowSubText]} - wrapperStyle={styles.chatItemComposeSecondaryRow} - leadingTextParentStyle={styles.chatItemComposeSecondaryRowOffset} /> ); default: return ( {this.props.translate('reportTypingIndicator.multipleUsers')} diff --git a/src/styles/styles.js b/src/styles/styles.js index dbce0a6b052d..75333fee8f86 100644 --- a/src/styles/styles.js +++ b/src/styles/styles.js @@ -644,7 +644,7 @@ const styles = { }, chatItemComposeSecondaryRow: { - height: 15, + minHeight: 15, marginBottom: 5, marginTop: 5, }, From 578e7937c08aff14bdd96a4b0fd23dd482ff91cf Mon Sep 17 00:00:00 2001 From: Tim Golen Date: Thu, 19 May 2022 10:07:32 -0600 Subject: [PATCH 5/8] Remove some debugging code --- src/components/YouAppearToBeOffline.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/YouAppearToBeOffline.js b/src/components/YouAppearToBeOffline.js index 70cc784100bf..09bd6514f22a 100644 --- a/src/components/YouAppearToBeOffline.js +++ b/src/components/YouAppearToBeOffline.js @@ -19,7 +19,7 @@ const propTypes = { const YouAppearToBeOffline = (props) => { if (!props.network.isOffline) { - //return null; + return null; } return ( From badf52ca3c68b51d3caad06dde241e51606f71c7 Mon Sep 17 00:00:00 2001 From: Tim Golen Date: Thu, 19 May 2022 10:19:02 -0600 Subject: [PATCH 6/8] Simplify the comment exceeded logic --- src/components/ExceededCommentLength.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/ExceededCommentLength.js b/src/components/ExceededCommentLength.js index 5b320deba711..91a1fcb87bbd 100644 --- a/src/components/ExceededCommentLength.js +++ b/src/components/ExceededCommentLength.js @@ -10,8 +10,7 @@ const propTypes = { }; const ExceededCommentLength = (props) => { - const hasExceededMaxCommentLength = props.commentLength > CONST.MAX_COMMENT_LENGTH; - if (!hasExceededMaxCommentLength) { + if (props.commentLength <= CONST.MAX_COMMENT_LENGTH) { return null; } From 657c286bc378b9089eda13470cfdabab9a915c6f Mon Sep 17 00:00:00 2001 From: Tim Golen Date: Tue, 24 May 2022 09:10:26 -0600 Subject: [PATCH 7/8] Rename component --- src/components/YouAppearToBeOffline.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/YouAppearToBeOffline.js b/src/components/YouAppearToBeOffline.js index 09bd6514f22a..0126ca1ff9e9 100644 --- a/src/components/YouAppearToBeOffline.js +++ b/src/components/YouAppearToBeOffline.js @@ -17,7 +17,7 @@ const propTypes = { ...withLocalizePropTypes, }; -const YouAppearToBeOffline = (props) => { +const OfflineIndicator = (props) => { if (!props.network.isOffline) { return null; } @@ -35,10 +35,10 @@ const YouAppearToBeOffline = (props) => { ); }; -YouAppearToBeOffline.propTypes = propTypes; -YouAppearToBeOffline.displayName = 'YouAppearToBeOffline'; +OfflineIndicator.propTypes = propTypes; +OfflineIndicator.displayName = 'OfflineIndicator'; export default compose( withLocalize, withNetwork(), -)(YouAppearToBeOffline); +)(OfflineIndicator); From 120803d278e14fed7232e7f9a7a275d0d81bd25b Mon Sep 17 00:00:00 2001 From: Tim Golen Date: Tue, 24 May 2022 09:13:40 -0600 Subject: [PATCH 8/8] Rename file and import --- .../{YouAppearToBeOffline.js => OfflineIndicator.js} | 0 src/pages/home/report/ReportActionCompose.js | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) rename src/components/{YouAppearToBeOffline.js => OfflineIndicator.js} (100%) diff --git a/src/components/YouAppearToBeOffline.js b/src/components/OfflineIndicator.js similarity index 100% rename from src/components/YouAppearToBeOffline.js rename to src/components/OfflineIndicator.js diff --git a/src/pages/home/report/ReportActionCompose.js b/src/pages/home/report/ReportActionCompose.js index e9e86f280c3b..017c0d0bd3db 100755 --- a/src/pages/home/report/ReportActionCompose.js +++ b/src/pages/home/report/ReportActionCompose.js @@ -42,7 +42,7 @@ import Tooltip from '../../../components/Tooltip'; import EmojiPickerButton from '../../../components/EmojiPicker/EmojiPickerButton'; import VirtualKeyboard from '../../../libs/VirtualKeyboard'; import canUseTouchScreen from '../../../libs/canUseTouchscreen'; -import YouAppearToBeOffline from '../../../components/YouAppearToBeOffline'; +import OfflineIndicator from '../../../components/OfflineIndicator'; import ExceededCommentLength from '../../../components/ExceededCommentLength'; const propTypes = { @@ -453,7 +453,7 @@ class ReportActionCompose extends React.Component { )} - +