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

Fix #28322

Closed
wants to merge 2 commits into from
Closed

Fix #28322

Show file tree
Hide file tree
Changes from all 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
6 changes: 6 additions & 0 deletions src/components/AnonymousReportFooter.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,24 @@ import reportPropTypes from '../pages/reportPropTypes';
import CONST from '../CONST';
import styles from '../styles/styles';
import * as Session from '../libs/actions/Session';
import participantPropTypes from './participantPropTypes';

const propTypes = {
/** The report currently being looked at */
report: reportPropTypes,

isSmallSizeLayout: PropTypes.bool,

/** Personal details of all the users */
personalDetails: PropTypes.objectOf(participantPropTypes),

...withLocalizePropTypes,
};

const defaultProps = {
report: {},
isSmallSizeLayout: false,
personalDetails: {},
};

function AnonymousReportFooter(props) {
Expand All @@ -31,6 +36,7 @@ function AnonymousReportFooter(props) {
<AvatarWithDisplayName
report={props.report}
size={CONST.AVATAR_SIZE.MEDIUM}
personalDetails={props.personalDetails}
isAnonymous
/>
</View>
Expand Down
21 changes: 1 addition & 20 deletions src/components/MultipleAvatars.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,27 +71,8 @@ const defaultProps = {
maxAvatarsInRow: CONST.AVATAR_ROW_SIZE.DEFAULT,
};

function getContainerStyles(size, isInReportAction) {
let containerStyles;

switch (size) {
case CONST.AVATAR_SIZE.SMALL:
containerStyles = [styles.emptyAvatarSmall, styles.emptyAvatarMarginSmall];
break;
case CONST.AVATAR_SIZE.SMALLER:
containerStyles = [styles.emptyAvatarSmaller, styles.emptyAvatarMarginSmaller];
break;
case CONST.AVATAR_SIZE.MEDIUM:
containerStyles = [styles.emptyAvatarMedium, styles.emptyAvatarMargin];
break;
default:
containerStyles = [styles.emptyAvatar, isInReportAction ? styles.emptyAvatarMarginChat : styles.emptyAvatarMargin];
}

return containerStyles;
}
function MultipleAvatars(props) {
let avatarContainerStyles = getContainerStyles(props.size, props.isInReportAction);
let avatarContainerStyles = StyleUtils.getContainerStyles(props.size, props.isInReportAction);
const singleAvatarStyle = props.size === CONST.AVATAR_SIZE.SMALL ? styles.singleAvatarSmall : styles.singleAvatar;
const secondAvatarStyles = [props.size === CONST.AVATAR_SIZE.SMALL ? styles.secondAvatarSmall : styles.secondAvatar, ...props.secondAvatarStyle];
const tooltipTexts = props.shouldShowTooltip ? _.pluck(props.icons, 'name') : [''];
Expand Down
2 changes: 1 addition & 1 deletion src/components/SubscriptAvatar.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const defaultProps = {
function SubscriptAvatar(props) {
const isSmall = props.size === CONST.AVATAR_SIZE.SMALL;
const subscriptStyle = props.size === CONST.AVATAR_SIZE.SMALL_NORMAL ? styles.secondAvatarSubscriptSmallNormal : styles.secondAvatarSubscript;
const containerStyle = isSmall ? styles.emptyAvatarSmall : styles.emptyAvatar;
const containerStyle = StyleUtils.getContainerStyles(props.size);
// Default the margin style to what is normal for small or normal sized avatars
let marginStyle = isSmall ? styles.emptyAvatarMarginSmall : styles.emptyAvatarMargin;

Expand Down
1 change: 1 addition & 0 deletions src/pages/home/ReportScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ function ReportScreen({
isComposerFullSize={isComposerFullSize}
onSubmitComment={onSubmitComment}
policies={policies}
personalDetails={personalDetails}
/>
</>
)}
Expand Down
6 changes: 6 additions & 0 deletions src/pages/home/report/ReportFooter.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import reportActionPropTypes from './reportActionPropTypes';
import reportPropTypes from '../../reportPropTypes';
import * as ReportUtils from '../../../libs/ReportUtils';
import * as Session from '../../../libs/actions/Session';
import participantPropTypes from '../../../components/participantPropTypes';

const propTypes = {
/** Report object for the current report */
Expand All @@ -34,6 +35,9 @@ const propTypes = {
/** The pending action when we are adding a chat */
pendingAction: PropTypes.string,

/** Personal details of all the users */
personalDetails: PropTypes.objectOf(participantPropTypes),

/** Whether the composer input should be shown */
shouldShowComposeInput: PropTypes.bool,

Expand All @@ -48,6 +52,7 @@ const defaultProps = {
reportActions: [],
onSubmitComment: () => {},
pendingAction: null,
personalDetails: {},
shouldShowComposeInput: true,
shouldDisableCompose: false,
};
Expand All @@ -68,6 +73,7 @@ function ReportFooter(props) {
<AnonymousReportFooter
report={props.report}
isSmallSizeLayout={isSmallSizeLayout}
personalDetails={props.personalDetails}
/>
)}
{isArchivedRoom && <ArchivedReportFooter report={props.report} />}
Expand Down
24 changes: 24 additions & 0 deletions src/styles/StyleUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1207,6 +1207,29 @@ function getAmountFontSizeAndLineHeight(baseFontSize: number, baseLineHeight: nu
};
}

/**
* Returns container styles for showing the icons in MultipleAvatars/SubscriptAvatar
*/
function getContainerStyles(size: string, isInReportAction = false): Array<ViewStyle | CSSProperties> {
let containerStyles: Array<ViewStyle | CSSProperties>;

switch (size) {
case CONST.AVATAR_SIZE.SMALL:
containerStyles = [styles.emptyAvatarSmall, styles.emptyAvatarMarginSmall];
break;
case CONST.AVATAR_SIZE.SMALLER:
containerStyles = [styles.emptyAvatarSmaller, styles.emptyAvatarMarginSmaller];
break;
case CONST.AVATAR_SIZE.MEDIUM:
containerStyles = [styles.emptyAvatarMedium, styles.emptyAvatarMargin];
break;
default:
containerStyles = [styles.emptyAvatar, isInReportAction ? styles.emptyAvatarMarginChat : styles.emptyAvatarMargin];
}

return containerStyles;
}

/**
* Get transparent color by setting alpha value 0 of the passed hex(#xxxxxx) color code
*/
Expand Down Expand Up @@ -1290,5 +1313,6 @@ export {
getCheckboxContainerStyle,
getDropDownButtonHeight,
getAmountFontSizeAndLineHeight,
getContainerStyles,
getTransparentColor,
};
Loading