Skip to content

Commit

Permalink
Merge pull request #42735 from s77rt/AvatarWithImagePicker-styles
Browse files Browse the repository at this point in the history
Fix AvatarWithImagePicker error styles
  • Loading branch information
marcaaron authored May 29, 2024
2 parents 9988663 + f40359a commit ee1196d
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 40 deletions.
5 changes: 2 additions & 3 deletions src/components/AvatarWithImagePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -303,12 +303,11 @@ function AvatarWithImagePicker({
}, [isMenuVisible, windowWidth]);

return (
<View style={StyleSheet.flatten([styles.alignItemsCenter, style])}>
<View style={style}>
<View style={styles.w100}>
<OfflineWithFeedback
errors={errors}
errorRowStyles={errorRowStyles}
style={type === CONST.ICON_TYPE_AVATAR && styles.alignItemsCenter}
onClose={onErrorClose}
>
<Tooltip
Expand All @@ -327,7 +326,7 @@ function AvatarWithImagePicker({
accessibilityLabel={translate('avatarWithImagePicker.editImage')}
disabled={isAvatarCropModalOpen || (disabled && !enablePreview)}
disabledStyle={disabledStyle}
style={[styles.pRelative, avatarStyle]}
style={[styles.pRelative, avatarStyle, type === CONST.ICON_TYPE_AVATAR && styles.alignSelfCenter]}
ref={anchorRef}
>
<OfflineWithFeedback pendingAction={pendingAction}>
Expand Down
1 change: 1 addition & 0 deletions src/pages/NewChatConfirmPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ function NewChatConfirmPage({newGroupDraft, allPersonalDetails}: NewChatConfirmP
editIcon={Expensicons.Camera}
editIconStyle={styles.smallEditIconAccount}
shouldUseStyleUtilityForAnchorPosition
style={styles.w100}
/>
</View>
<MenuItemWithTopDescription
Expand Down
82 changes: 45 additions & 37 deletions src/pages/ReportDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -230,34 +230,51 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD
/>
) : null;

const renderAvatar =
isGroupChat && !isThread ? (
<AvatarWithImagePicker
source={icons[0].source}
avatarID={icons[0].id}
isUsingDefaultAvatar={!report.avatarUrl}
size={CONST.AVATAR_SIZE.XLARGE}
avatarStyle={styles.avatarXLarge}
shouldDisableViewPhoto
onImageRemoved={() => {
// Calling this without a file will remove the avatar
Report.updateGroupChatAvatar(report.reportID ?? '');
}}
onImageSelected={(file) => Report.updateGroupChatAvatar(report.reportID ?? '', file)}
editIcon={Expensicons.Camera}
editIconStyle={styles.smallEditIconAccount}
pendingAction={report.pendingFields?.avatar ?? undefined}
errors={report.errorFields?.avatar ?? null}
errorRowStyles={styles.mt6}
onErrorClose={() => Report.clearAvatarErrors(report.reportID ?? '')}
shouldUseStyleUtilityForAnchorPosition
/>
) : (
<RoomHeaderAvatars
icons={icons}
reportID={report?.reportID}
/>
const renderAvatar = useMemo(() => {
if (isMoneyRequestReport || isInvoiceReport) {
return (
<View style={styles.mb3}>
<MultipleAvatars
icons={icons}
size={CONST.AVATAR_SIZE.LARGE}
/>
</View>
);
}
if (isGroupChat && !isThread) {
return (
<AvatarWithImagePicker
source={icons[0].source}
avatarID={icons[0].id}
isUsingDefaultAvatar={!report.avatarUrl}
size={CONST.AVATAR_SIZE.XLARGE}
avatarStyle={styles.avatarXLarge}
shouldDisableViewPhoto
onImageRemoved={() => {
// Calling this without a file will remove the avatar
Report.updateGroupChatAvatar(report.reportID ?? '');
}}
onImageSelected={(file) => Report.updateGroupChatAvatar(report.reportID ?? '', file)}
editIcon={Expensicons.Camera}
editIconStyle={styles.smallEditIconAccount}
pendingAction={report.pendingFields?.avatar ?? undefined}
errors={report.errorFields?.avatar ?? null}
errorRowStyles={styles.mt6}
onErrorClose={() => Report.clearAvatarErrors(report.reportID ?? '')}
shouldUseStyleUtilityForAnchorPosition
style={[styles.w100, styles.mb3]}
/>
);
}
return (
<View style={styles.mb3}>
<RoomHeaderAvatars
icons={icons}
reportID={report?.reportID}
/>
</View>
);
}, [report, icons, isMoneyRequestReport, isInvoiceReport, isGroupChat, isThread, styles]);

const reportName =
ReportUtils.isDeprecatedGroupDM(report) || ReportUtils.isGroupChat(report)
Expand All @@ -273,16 +290,7 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD
/>
<ScrollView style={[styles.flex1]}>
<View style={styles.reportDetailsTitleContainer}>
<View style={styles.mb3}>
{isMoneyRequestReport || isInvoiceReport ? (
<MultipleAvatars
icons={icons}
size={CONST.AVATAR_SIZE.LARGE}
/>
) : (
renderAvatar
)}
</View>
{renderAvatar}
<View style={[styles.reportDetailsRoomInfo, styles.mw100]}>
<View style={[styles.alignSelfCenter, styles.w100, styles.mt1]}>
<DisplayNames
Expand Down

0 comments on commit ee1196d

Please sign in to comment.