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 8 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
17 changes: 12 additions & 5 deletions src/components/ReportWelcomeText.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import compose from '../libs/compose';
import * as ReportUtils from '../libs/ReportUtils';
import * as OptionsListUtils from '../libs/OptionsListUtils';
import ONYXKEYS from '../ONYXKEYS';
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 @@ -85,7 +88,7 @@ const ReportWelcomeText = (props) => {
<Text style={styles.textAlignCenter}>
{roomWelcomeMessage.phrase1}
</Text>
<Text style={[styles.textStrong]}>
<Text style={[styles.textStrong]} onPress={() => Navigation.navigate(ROUTES.getReportDetailsRoute(props.report.reportID))}>
{props.report.reportName}
</Text>
<Text>
Expand All @@ -99,11 +102,15 @@ const ReportWelcomeText = (props) => {
<Text style={styles.textAlignCenter}>
{props.translate('reportActionsView.beginningOfChatHistory')}
</Text>
{_.map(displayNamesWithTooltips, ({displayName, pronouns}, index) => (
{_.map(displayNamesWithTooltips, ({
displayName, pronouns, tooltip,
}, index) => (
<Text key={displayName}>
<Text style={[styles.textStrong]}>
{displayName}
</Text>
<Tooltip text={tooltip}>
<Text style={[styles.textStrong]} onPress={() => Navigation.navigate(ROUTES.getDetailsRoute(participants[index]))}>
{displayName}
</Text>
</Tooltip>
{!_.isEmpty(pronouns) && <Text>{` (${pronouns})`}</Text>}
{(index === displayNamesWithTooltips.length - 1) && <Text>.</Text>}
{(index === displayNamesWithTooltips.length - 2) && <Text>{` ${props.translate('common.and')} `}</Text>}
Expand Down
15 changes: 2 additions & 13 deletions src/components/Tooltip/index.native.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,21 @@
import React from 'react';
import {View} from 'react-native';
import PropTypes from 'prop-types';

// We can't use the common component for the Tooltip as Web implementation uses DOM specific method to
// render the View which is not present on the Mobile.
const propTypes = {
/** Styles to be assigned to the Tooltip wrapper views */
containerStyles: PropTypes.arrayOf(PropTypes.object),

/** Children to wrap with Tooltip. */
children: PropTypes.node.isRequired,
};

const defaultProps = {
containerStyles: [],
};

/**
* @param {propTypes} props
* @returns {ReactNodeLike}
*/
const Tooltip = props => (
<View style={props.containerStyles}>
{props.children}
</View>
props.children
);

Tooltip.propTypes = propTypes;
Tooltip.defaultProps = defaultProps;
Tooltip.displayName = 'Tooltip';

export default Tooltip;
21 changes: 21 additions & 0 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import * as Localize from './Localize';
import * as LocalePhoneNumber from './LocalePhoneNumber';
import * as Expensicons from '../components/Icon/Expensicons';
import md5 from './md5';
import Navigation from './Navigation/Navigation';
import ROUTES from '../ROUTES';

let sessionEmail;
Onyx.connect({
Expand Down Expand Up @@ -481,6 +483,24 @@ function getReportName(report, personalDetailsForParticipants = {}, policies = {
return _.map(displayNamesWithTooltips, ({displayName}) => displayName).join(', ');
}

/**
* Navigate to the details page of a given report
*
* @param {Object} report
* @param {Array} participants
*/
function navigateToDetailsPage(report, participants) {
Tushu17 marked this conversation as resolved.
Show resolved Hide resolved
if (isChatRoom(report) || isPolicyExpenseChat(report)) {
Navigation.navigate(ROUTES.getReportDetailsRoute(report.reportID));
return;
}
if (participants.length === 1) {
Navigation.navigate(ROUTES.getDetailsRoute(participants[0]));
return;
}
Navigation.navigate(ROUTES.getReportParticipantsRoute(report.reportID));
}

export {
getReportParticipantsTitle,
isReportMessageAttachment,
Expand All @@ -507,4 +527,5 @@ export {
getRoomWelcomeMessage,
getDisplayNamesWithTooltips,
getReportName,
navigateToDetailsPage,
};
15 changes: 1 addition & 14 deletions src/pages/home/HeaderView.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import * as Report from '../../libs/actions/Report';
import withWindowDimensions, {windowDimensionsPropTypes} from '../../components/withWindowDimensions';
import MultipleAvatars from '../../components/MultipleAvatars';
import SubscriptAvatar from '../../components/SubscriptAvatar';
import Navigation from '../../libs/Navigation/Navigation';
import ROUTES from '../../ROUTES';
import DisplayNames from '../../components/DisplayNames';
import * as OptionsListUtils from '../../libs/OptionsListUtils';
import participantPropTypes from '../../components/participantPropTypes';
Expand All @@ -28,9 +26,6 @@ import Text from '../../components/Text';
import Tooltip from '../../components/Tooltip';

const propTypes = {
/** The ID of the report */
reportID: PropTypes.number.isRequired,

/** Toggles the navigationMenu open and closed */
onNavigationMenuButtonClicked: PropTypes.func.isRequired,

Expand Down Expand Up @@ -113,15 +108,7 @@ const HeaderView = (props) => {
]}
>
<Pressable
onPress={() => {
if (isChatRoom || isPolicyExpenseChat) {
return Navigation.navigate(ROUTES.getReportDetailsRoute(props.reportID));
}
if (participants.length === 1) {
return Navigation.navigate(ROUTES.getDetailsRoute(participants[0]));
}
Navigation.navigate(ROUTES.getReportParticipantsRoute(props.reportID));
}}
onPress={() => ReportUtils.navigateToDetailsPage(props.report, participants)}
style={[styles.flexRow, styles.alignItemsCenter, styles.flex1]}
>
{shouldShowSubscript ? (
Expand Down
16 changes: 10 additions & 6 deletions src/pages/home/report/ReportActionItemCreated.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
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';
Expand All @@ -17,7 +18,6 @@ const propTypes = {

/** Whether the user is not an admin of policyExpenseChat chat */
isOwnPolicyExpenseChat: PropTypes.bool,

}),

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

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

return (
<View style={[
styles.chatContent,
Expand All @@ -46,10 +48,12 @@ const ReportActionItemCreated = (props) => {
]}
>
<View style={[styles.justifyContentCenter, styles.alignItemsCenter, styles.flex1]}>
<RoomHeaderAvatars
icons={icons}
shouldShowLargeAvatars={isPolicyExpenseChat}
/>
<Pressable onPress={() => ReportUtils.navigateToDetailsPage(props.report, participants)}>
<RoomHeaderAvatars
icons={icons}
shouldShowLargeAvatars={isPolicyExpenseChat}
/>
</Pressable>
<ReportWelcomeText report={props.report} />
</View>
</View>
Expand Down