Skip to content

Commit

Permalink
Merge pull request Expensify#9095 from Expensify/tgolen-move-istyping
Browse files Browse the repository at this point in the history
Move all the compose meta data to be above the compose input
  • Loading branch information
amyevans authored May 27, 2022
2 parents 3e52b9a + 120803d commit 70479c3
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 64 deletions.
27 changes: 27 additions & 0 deletions src/components/ExceededCommentLength.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
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) => {
if (props.commentLength <= CONST.MAX_COMMENT_LENGTH) {
return null;
}

return (
<Text style={[styles.textMicro, styles.textDanger]}>
{`${props.commentLength}/${CONST.MAX_COMMENT_LENGTH}`}
</Text>
);
};

ExceededCommentLength.propTypes = propTypes;
ExceededCommentLength.displayName = 'ExceededCommentLength';

export default ExceededCommentLength;
44 changes: 44 additions & 0 deletions src/components/OfflineIndicator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import React from 'react';
import {View} from 'react-native';
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 OfflineIndicator = (props) => {
if (!props.network.isOffline) {
return null;
}
return (
<View style={[styles.flexRow]}>
<Icon
src={Expensicons.Offline}
width={variables.iconSizeExtraSmall}
height={variables.iconSizeExtraSmall}
/>
<Text style={[styles.ml2, styles.chatItemComposeSecondaryRowSubText]}>
{props.translate('reportActionCompose.youAppearToBeOffline')}
</Text>
</View>
);
};

OfflineIndicator.propTypes = propTypes;
OfflineIndicator.displayName = 'OfflineIndicator';

export default compose(
withLocalize,
withNetwork(),
)(OfflineIndicator);
32 changes: 12 additions & 20 deletions src/pages/home/report/ParticipantLocalTime.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -60,23 +57,18 @@ class ParticipantLocalTime extends PureComponent {
: this.props.participant.displayName);

return (
<View style={[styles.chatItemComposeSecondaryRow]}>
<Text
style={[
styles.chatItemComposeSecondaryRowSubText,
styles.chatItemComposeSecondaryRowOffset,
]}
numberOfLines={1}
>
{this.props.translate(
'reportActionCompose.localTime',
{
user: reportRecipientDisplayName,
time: this.state.localTime,
},
)}
</Text>
</View>
<Text
style={[styles.chatItemComposeSecondaryRowSubText]}
numberOfLines={1}
>
{this.props.translate(
'reportActionCompose.localTime',
{
user: reportRecipientDisplayName,
time: this.state.localTime,
},
)}
</Text>
);
}
}
Expand Down
61 changes: 25 additions & 36 deletions src/pages/home/report/ReportActionCompose.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,24 @@ 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';
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 OfflineIndicator from '../../../components/OfflineIndicator';
import ExceededCommentLength from '../../../components/ExceededCommentLength';

const propTypes = {
/** Beta features list */
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -447,9 +443,28 @@ class ReportActionCompose extends React.Component {
const hasExceededMaxCommentLength = this.comment.length > CONST.MAX_COMMENT_LENGTH;

return (
<View style={[shouldShowReportRecipientLocalTime && styles.chatItemComposeWithFirstRow]}>
{shouldShowReportRecipientLocalTime
&& <ParticipantLocalTime participant={reportRecipient} />}
<View style={[styles.chatItemComposeWithFirstRow]}>
<View style={[styles.flexRow, styles.chatItemComposeSecondaryRow, styles.chatItemComposeSecondaryRowOffset, styles.flexWrap]}>
{shouldShowReportRecipientLocalTime
&& (
<View style={[styles.mr3]}>
<ParticipantLocalTime participant={reportRecipient} />
</View>
)}

<View style={[styles.mr3]}>
<OfflineIndicator />
</View>

<View style={[styles.mr3]}>
<ExceededCommentLength commentLength={this.comment.length} />
</View>

<View style={[styles.mr3]}>
<ReportTypingIndicator reportID={this.props.reportID} />
</View>
</View>

<View style={[
(!isBlockedFromConcierge && (this.state.isFocused || this.state.isDraggingOver))
? styles.chatItemComposeBoxFocusedColor
Expand Down Expand Up @@ -589,31 +604,6 @@ class ReportActionCompose extends React.Component {
</Tooltip>
</View>
</View>
<View style={[styles.chatItemComposeSecondaryRow, styles.flexRow, styles.justifyContentBetween, styles.alignItemsCenter]}>
<View>
{this.props.network.isOffline ? (
<View style={[
styles.chatItemComposeSecondaryRowOffset,
styles.flexRow,
styles.alignItemsCenter]}
>
<Icon
src={Expensicons.Offline}
width={variables.iconSizeExtraSmall}
height={variables.iconSizeExtraSmall}
/>
<Text style={[styles.ml2, styles.chatItemComposeSecondaryRowSubText]}>
{this.props.translate('reportActionCompose.youAppearToBeOffline')}
</Text>
</View>
) : <ReportTypingIndicator reportID={this.props.reportID} />}
</View>
{hasExceededMaxCommentLength && (
<Text style={[styles.textMicro, styles.textDanger, styles.chatItemComposeSecondaryRow]}>
{`${this.comment.length}/${CONST.MAX_COMMENT_LENGTH}`}
</Text>
)}
</View>
</View>
);
}
Expand All @@ -628,7 +618,6 @@ export default compose(
withNavigationFocus,
withLocalize,
withPersonalDetails(),
withNetwork(),
withOnyx({
betas: {
key: ONYXKEYS.BETAS,
Expand Down
11 changes: 4 additions & 7 deletions src/pages/home/report/ReportTypingIndicator.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,24 +49,21 @@ 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 (
<TextWithEllipsis
leadingText={PersonalDetails.getDisplayName(this.state.usersTyping[0])}
trailingText={` ${this.props.translate('reportTypingIndicator.isTyping')}`}
textStyle={[styles.chatItemComposeSecondaryRowSubText]}
wrapperStyle={styles.chatItemComposeSecondaryRow}
leadingTextParentStyle={styles.chatItemComposeSecondaryRowOffset}
/>
);

default:
return (
<Text
style={[
styles.chatItemComposeSecondaryRowSubText,
styles.chatItemComposeSecondaryRowOffset,
]}
style={[styles.chatItemComposeSecondaryRowSubText]}
numberOfLines={1}
>
{this.props.translate('reportTypingIndicator.multipleUsers')}
Expand Down
2 changes: 1 addition & 1 deletion src/styles/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ const styles = {
},

chatItemComposeSecondaryRow: {
height: 15,
minHeight: 15,
marginBottom: 5,
marginTop: 5,
},
Expand Down

0 comments on commit 70479c3

Please sign in to comment.