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

make avatar and welcome message pressable #8409

Merged
merged 9 commits into from
May 17, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
29 changes: 22 additions & 7 deletions src/components/ReportWelcomeText.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import lodashGet from 'lodash/get';
import Str from 'expensify-common/lib/str';
import {withOnyx} from 'react-native-onyx';
import _ from 'underscore';
import {Pressable} from 'react-native';
import styles from '../styles/styles';
import Text from './Text';
import withLocalize, {withLocalizePropTypes} from './withLocalize';
Expand All @@ -12,6 +13,9 @@ import * as ReportUtils from '../libs/reportUtils';
import * as OptionsListUtils from '../libs/OptionsListUtils';
import ONYXKEYS from '../ONYXKEYS';
import CONST from '../CONST';
import Navigation from '../libs/Navigation/Navigation';
import ROUTES from '../ROUTES';
import Tooltip from './Tooltip';

const personalDetailsPropTypes = PropTypes.shape({
/** The login of the person (either email or phone number) */
Expand Down Expand Up @@ -70,6 +74,7 @@ const ReportWelcomeText = (props) => {
displayName: isMultipleParticipant ? shortName : longNameLocalized,
tooltip: Str.removeSMSDomain(login),
pronouns: finalPronouns,
login,
};
},
);
Expand Down Expand Up @@ -103,9 +108,13 @@ const ReportWelcomeText = (props) => {
<Text style={styles.textAlignCenter}>
{roomWelcomeMessage.phrase1}
</Text>
<Text style={[styles.textStrong]}>
{props.report.reportName}
</Text>
<Pressable
onPress={() => Navigation.navigate(ROUTES.getReportDetailsRoute(props.report.reportID))}
Tushu17 marked this conversation as resolved.
Show resolved Hide resolved
>
<Text style={[styles.textStrong]}>
{props.report.reportName}
</Text>
</Pressable>
<Text>
{roomWelcomeMessage.phrase2}
</Text>
Expand All @@ -117,11 +126,17 @@ const ReportWelcomeText = (props) => {
<Text style={styles.textAlignCenter}>
{props.translate('reportActionsView.beginningOfChatHistory')}
</Text>
{_.map(displayNamesWithTooltips, ({displayName, pronouns}, index) => (
{_.map(displayNamesWithTooltips, ({
displayName, pronouns, login, tooltip,
}, index) => (
<Text key={displayName}>
<Text style={[styles.textStrong]}>
{displayName}
</Text>
<Tooltip text={tooltip}>
<Pressable onPress={() => Navigation.navigate(ROUTES.getDetailsRoute(login))}>
<Text style={[styles.textStrong]}>
{displayName}
</Text>
</Pressable>
</Tooltip>
Tushu17 marked this conversation as resolved.
Show resolved Hide resolved
{!_.isEmpty(pronouns) && <Text>{` (${pronouns})`}</Text>}
{(index === displayNamesWithTooltips.length - 1) && <Text>.</Text>}
{(index === displayNamesWithTooltips.length - 2) && <Text>{` ${props.translate('common.and')} `}</Text>}
Expand Down
30 changes: 25 additions & 5 deletions src/pages/home/report/ReportActionItemCreated.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import React from 'react';
import {View} from 'react-native';
import {Pressable, View} from 'react-native';
import {withOnyx} from 'react-native-onyx';
import PropTypes from 'prop-types';
import lodashGet from 'lodash/get';
import ONYXKEYS from '../../../ONYXKEYS';
import RoomHeaderAvatars from '../../../components/RoomHeaderAvatars';
import ReportWelcomeText from '../../../components/ReportWelcomeText';
import participantPropTypes from '../../../components/participantPropTypes';
import * as ReportUtils from '../../../libs/reportUtils';
import styles from '../../../styles/styles';
import Navigation from '../../../libs/Navigation/Navigation';
import ROUTES from '../../../ROUTES';

const propTypes = {
/** The report currently being looked at */
Expand All @@ -18,6 +21,8 @@ const propTypes = {
/** Whether the user is not an admin of policyExpenseChat chat */
isOwnPolicyExpenseChat: PropTypes.bool,

/** ID of the report */
reportID: PropTypes.number,
}),

/** Personal details of all the users */
Expand All @@ -36,8 +41,21 @@ const defaultProps = {
};

const ReportActionItemCreated = (props) => {
const participants = lodashGet(props.report, 'participants', []);
const isChatRoom = ReportUtils.isChatRoom(props.report);
const isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(props.report);
const icons = ReportUtils.getIcons(props.report, props.personalDetails, props.policies);

function navigateToDetailsPage() {
if (isChatRoom || isPolicyExpenseChat) {
return Navigation.navigate(ROUTES.getReportDetailsRoute(props.report.reportID));
}
if (participants.length === 1) {
return Navigation.navigate(ROUTES.getDetailsRoute(participants[0]));
Tushu17 marked this conversation as resolved.
Show resolved Hide resolved
}
Navigation.navigate(ROUTES.getReportParticipantsRoute(props.report.reportID));
}

Tushu17 marked this conversation as resolved.
Show resolved Hide resolved
return (
<View style={[
styles.chatContent,
Expand All @@ -46,10 +64,12 @@ const ReportActionItemCreated = (props) => {
]}
>
<View style={[styles.justifyContentCenter, styles.alignItemsCenter, styles.flex1]}>
<RoomHeaderAvatars
icons={icons}
shouldShowLargeAvatars={isPolicyExpenseChat}
/>
<Pressable onPress={navigateToDetailsPage}>
<RoomHeaderAvatars
icons={icons}
shouldShowLargeAvatars={isPolicyExpenseChat}
/>
</Pressable>
<ReportWelcomeText report={props.report} />
</View>
</View>
Expand Down