Skip to content

Commit

Permalink
Merge pull request #14255 from Expensify/dangrous-embiggenavatars
Browse files Browse the repository at this point in the history
Make avatars in chat welcome messages always big
  • Loading branch information
cristipaval authored Jan 24, 2023
2 parents a10949d + bb3a7d1 commit 4d86f17
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 32 deletions.
1 change: 1 addition & 0 deletions src/CONST.js
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,7 @@ const CONST = {
SMALLER: 'smaller',
SUBSCRIPT: 'subscript',
SMALL_SUBSCRIPT: 'small-subscript',
LARGE_BORDERED: 'large-bordered',
},
OPTION_MODE: {
COMPACT: 'compact',
Expand Down
31 changes: 4 additions & 27 deletions src/components/RoomHeaderAvatars.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,10 @@ import * as StyleUtils from '../styles/StyleUtils';
const propTypes = {
/** Array of avatar URLs or icons */
icons: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.func])),

/** Whether show large Avatars */
shouldShowLargeAvatars: PropTypes.bool,
};

const defaultProps = {
icons: [],
shouldShowLargeAvatars: false,
};

const RoomHeaderAvatars = (props) => {
Expand All @@ -38,32 +34,13 @@ const RoomHeaderAvatars = (props) => {
);
}

if (props.shouldShowLargeAvatars) {
return (
<View style={[styles.flexRow, styles.wAuto, styles.justifyContentCenter, styles.alignItemsCenter]}>
<View style={styles.leftSideLargeAvatar}>
<Avatar
source={props.icons[1]}
imageStyles={[styles.avatarLarge]}
size={CONST.AVATAR_SIZE.LARGE}
fill={themeColors.iconSuccessFill}
/>
</View>
<View style={[styles.rightSideLargeAvatar, StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)]}>
<Avatar
source={props.icons[0]}
imageStyles={[styles.avatarLarge]}
size={CONST.AVATAR_SIZE.LARGE}
/>
</View>
</View>
);
}

const iconsToDisplay = props.icons.slice(0, CONST.REPORT.MAX_PREVIEW_AVATARS);

const iconStyle = [
styles.roomHeaderAvatar,
StyleUtils.getAvatarStyle(CONST.AVATAR_SIZE.MEDIUM),

// Due to border-box box-sizing, the Avatars have to be larger when bordered to visually match size with non-bordered Avatars
StyleUtils.getAvatarStyle(CONST.AVATAR_SIZE.LARGE_BORDERED),
];
return (
<View pointerEvents="none">
Expand Down
1 change: 0 additions & 1 deletion src/pages/ReportDetailsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ class ReportDetailsPage extends Component {
<View style={styles.mb4}>
<RoomHeaderAvatars
icons={ReportUtils.getIcons(this.props.report, this.props.personalDetails, this.props.policies)}
shouldShowLargeAvatars={isPolicyExpenseChat}
/>
</View>
<View style={[styles.reportDetailsRoomInfo, styles.mw100]}>
Expand Down
2 changes: 0 additions & 2 deletions src/pages/home/report/ReportActionItemCreated.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ const defaultProps = {
};

const ReportActionItemCreated = (props) => {
const isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(props.report);
const icons = ReportUtils.getIcons(props.report, props.personalDetails, props.policies);
return (
<OfflineWithFeedback
Expand All @@ -57,7 +56,6 @@ const ReportActionItemCreated = (props) => {
<Pressable onPress={() => ReportUtils.navigateToDetailsPage(props.report)}>
<RoomHeaderAvatars
icons={icons}
shouldShowLargeAvatars={isPolicyExpenseChat}
/>
</Pressable>
<ReportWelcomeText report={props.report} />
Expand Down
2 changes: 2 additions & 0 deletions src/styles/StyleUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ function getAvatarSize(size) {
[CONST.AVATAR_SIZE.SMALLER]: variables.avatarSizeSmaller,
[CONST.AVATAR_SIZE.LARGE]: variables.avatarSizeLarge,
[CONST.AVATAR_SIZE.MEDIUM]: variables.avatarSizeMedium,
[CONST.AVATAR_SIZE.LARGE_BORDERED]: variables.avatarSizeLargeBordered,
};

return AVATAR_SIZES[size];
}

Expand Down
7 changes: 5 additions & 2 deletions src/styles/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -2006,15 +2006,18 @@ const styles = {
left: 0,
backgroundColor: themeColors.overlay,
opacity: variables.overlayOpacity,
borderRadius: 88,
},

avatarInnerTextChat: {
color: themeColors.textLight,
fontSize: variables.fontSizeNormal,
left: 1,
fontSize: variables.fontSizeXLarge,
fontFamily: fontFamily.EXP_NEW_KANSAS_MEDIUM,
textAlign: 'center',
fontWeight: 'normal',
position: 'absolute',
width: 88,
left: -16,
},

pageWrapper: {
Expand Down
1 change: 1 addition & 0 deletions src/styles/variables.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export default {
componentBorderRadiusRounded: 20,
buttonBorderRadius: 100,
avatarSizeLarge: 80,
avatarSizeLargeBordered: 88,
avatarSizeMedium: 52,
avatarSizeNormal: 40,
avatarSizeSmall: 28,
Expand Down

0 comments on commit 4d86f17

Please sign in to comment.