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

feat: update ProfilePage #42188

Merged
Show file tree
Hide file tree
Changes from 5 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
20 changes: 12 additions & 8 deletions src/components/PromotedActionsBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import useLocalize from '@hooks/useLocalize';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import * as HeaderUtils from '@libs/HeaderUtils';
import * as Localize from '@libs/Localize';
import * as ReportActions from '@userActions/Report';
import type OnyxReport from '@src/types/onyx/Report';
import Button from './Button';
Expand All @@ -20,7 +21,7 @@ type ReportPromotedAction = (report: OnyxReport) => PromotedAction;

type PromotedActionsType = {
pin: ReportPromotedAction;
// message: (accountID: number) => PromotedAction;
message: (accountID: number) => PromotedAction;
// join: ReportPromotedAction;
// share: ReportPromotedAction;
// hold: () => PromotedAction;
Expand All @@ -31,13 +32,12 @@ const PromotedActions = {
key: 'pin',
...HeaderUtils.getPinMenuItem(report),
}),
// TODO: Uncomment the following lines when the corresponding features are implemented
// message: (accountID) => ({
// key: 'message',
// icon: Expensicons.CommentBubbles,
// text: Localize.translateLocal('common.message'),
// onSelected: () => ReportActions.navigateToAndOpenReportWithAccountIDs([accountID]),
// }),
message: (accountID) => ({
key: 'message',
icon: Expensicons.CommentBubbles,
text: Localize.translateLocal('common.message'),
onSelected: () => ReportActions.navigateToAndOpenReportWithAccountIDs([accountID]),
}),
// join: (report) => ({
// key: 'join',
// icon: Expensicons.CommentBubbles,
Expand Down Expand Up @@ -81,6 +81,10 @@ function PromotedActionsBar({report, promotedActions, containerStyle, shouldShow
const [isLastMemberLeavingGroupModalVisible, setIsLastMemberLeavingGroupModalVisible] = useState(false);
const {translate} = useLocalize();

if (promotedActions.length === 0) {
return null;
}

return (
<View style={[styles.flexRow, styles.ph5, styles.mb5, styles.gap2, styles.mw100, styles.w100, containerStyle]}>
{/* TODO: Remove the `Leave` button when @src/pages/ReportDetailsPage.tsx is updated */}
Expand Down
37 changes: 22 additions & 15 deletions src/pages/ProfilePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import MenuItem from '@components/MenuItem';
import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription';
import OfflineWithFeedback from '@components/OfflineWithFeedback';
import PressableWithoutFocus from '@components/Pressable/PressableWithoutFocus';
import type {PromotedAction} from '@components/PromotedActionsBar';
import PromotedActionsBar, {PromotedActions} from '@components/PromotedActionsBar';
import ScreenWrapper from '@components/ScreenWrapper';
import ScrollView from '@components/ScrollView';
import Text from '@components/Text';
Expand Down Expand Up @@ -143,6 +145,18 @@ function ProfilePage({route}: ProfilePageProps) {
}
}, [accountID]);

const promotedActions = useMemo(() => {
const result: PromotedAction[] = [];
if (report) {
result.push(PromotedActions.pin(report));
}

if (!isCurrentUser && !SessionActions.isAnonymousUser()) {
result.push(PromotedActions.message(accountID));
}
return result;
}, [accountID, isCurrentUser, report]);

return (
<ScreenWrapper testID={ProfilePage.displayName}>
<FullPageNotFoundView shouldShow={shouldShowBlockingView || CONST.RESTRICTED_ACCOUNT_IDS.includes(accountID)}>
Expand All @@ -153,16 +167,16 @@ function ProfilePage({route}: ProfilePageProps) {
<View style={[styles.containerWithSpaceBetween, styles.pointerEventsBoxNone]}>
{hasMinimumDetails && (
<ScrollView>
<View style={styles.avatarSectionWrapper}>
<View style={[styles.avatarSectionWrapper, styles.pb0]}>
<PressableWithoutFocus
style={[styles.noOutline]}
style={[styles.noOutline, styles.mb4]}
onPress={() => Navigation.navigate(ROUTES.PROFILE_AVATAR.getRoute(String(accountID)))}
accessibilityLabel={translate('common.profile')}
accessibilityRole={CONST.ACCESSIBILITY_ROLE.IMAGEBUTTON}
>
<OfflineWithFeedback pendingAction={details?.pendingFields?.avatar}>
<Avatar
containerStyles={[styles.avatarXLarge, styles.mb3]}
containerStyles={[styles.avatarXLarge]}
imageStyles={[styles.avatarXLarge]}
source={UserUtils.getAvatar(avatar, accountID)}
size={CONST.AVATAR_SIZE.XLARGE}
Expand All @@ -172,12 +186,16 @@ function ProfilePage({route}: ProfilePageProps) {
</PressableWithoutFocus>
{Boolean(displayName) && (
<Text
style={[styles.textHeadline, styles.pre, styles.mb6, styles.w100, styles.textAlignCenter]}
style={[styles.textHeadline, styles.pre, styles.mb8, styles.w100, styles.textAlignCenter]}
numberOfLines={1}
>
{displayName}
</Text>
)}
<PromotedActionsBar
promotedActions={promotedActions}
containerStyle={[styles.ph0, styles.mb8]}
/>
{hasStatus && (
<View style={[styles.mb6, styles.detailsPageSectionContainer, styles.mw100]}>
<Text
Expand Down Expand Up @@ -225,17 +243,6 @@ function ProfilePage({route}: ProfilePageProps) {
title={notificationPreference}
description={translate('notificationPreferencesPage.label')}
onPress={() => Navigation.navigate(ROUTES.REPORT_SETTINGS_NOTIFICATION_PREFERENCES.getRoute(report.reportID))}
wrapperStyle={[styles.mtn6, styles.mb5]}
/>
)}
{!isCurrentUser && !SessionActions.isAnonymousUser() && (
<MenuItem
title={`${translate('common.message')}${displayName}`}
titleStyle={styles.flex1}
icon={Expensicons.ChatBubble}
onPress={() => ReportActions.navigateToAndOpenReportWithAccountIDs([accountID])}
wrapperStyle={styles.breakAll}
shouldShowRightIcon
/>
)}
{!isEmptyObject(report) && report.reportID && !isCurrentUser && (
Expand Down
Loading