Skip to content
Merged
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
21 changes: 11 additions & 10 deletions src/components/AnonymousReportFooter.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import React from 'react';
import {View, Text} from 'react-native';
import PropTypes from 'prop-types';
import Button from './Button';
import AvatarWithDisplayName from './AvatarWithDisplayName';
import ExpensifyWordmark from './ExpensifyWordmark';
import compose from '../libs/compose';
import withWindowDimensions, {windowDimensionsPropTypes} from './withWindowDimensions';
import withLocalize, {withLocalizePropTypes} from './withLocalize';
import reportPropTypes from '../pages/reportPropTypes';
import CONST from '../CONST';
Expand All @@ -15,32 +14,34 @@ const propTypes = {
/** The report currently being looked at */
report: reportPropTypes,

...windowDimensionsPropTypes,
isSmallSizeLayout: PropTypes.bool,

...withLocalizePropTypes,
};

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

function AnonymousReportFooter(props) {
return (
<View style={styles.anonymousRoomFooter}>
<View style={styles.anonymousRoomFooter(props.isSmallSizeLayout)}>
<View style={[styles.flexRow]}>
<AvatarWithDisplayName
report={props.report}
size={CONST.AVATAR_SIZE.MEDIUM}
isAnonymous
/>
</View>
<View style={[styles.flexRow, styles.alignItemsCenter]}>
<View style={styles.mr4}>
<View style={[props.isSmallScreenWidth ? styles.alignItemsStart : styles.alignItemsEnd]}>
<View style={styles.anonymousRoomFooterWordmarkAndLogoContainer(props.isSmallSizeLayout)}>
<View style={[props.isSmallSizeLayout ? styles.mr1 : styles.mr4, styles.flexShrink1]}>
<View style={[props.isSmallSizeLayout ? styles.alignItemsStart : styles.alignItemsEnd]}>
<ExpensifyWordmark style={styles.anonymousRoomFooterLogo} />
</View>
<Text style={[styles.textNormal, styles.textWhite]}>{props.translate('anonymousReportFooter.logoTagline')}</Text>
<Text style={styles.anonymousRoomFooterLogoTaglineText}>{props.translate('anonymousReportFooter.logoTagline')}</Text>
</View>
<View style={styles.anonymousRoomFooterSignInButton}>
<View style={[styles.anonymousRoomFooterSignInButton]}>
<Button
medium
success
Expand All @@ -57,4 +58,4 @@ AnonymousReportFooter.propTypes = propTypes;
AnonymousReportFooter.defaultProps = defaultProps;
AnonymousReportFooter.displayName = 'AnonymousReportFooter';

export default compose(withWindowDimensions, withLocalize)(AnonymousReportFooter);
export default withLocalize(AnonymousReportFooter);
5 changes: 4 additions & 1 deletion src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ let sessionEmail;
let sessionAccountID;
let currentUserEmail;
let currentUserAccountID;
let isAnonymousUser;

Onyx.connect({
key: ONYXKEYS.SESSION,
callback: (val) => {
Expand All @@ -37,6 +39,7 @@ Onyx.connect({
sessionAccountID = val.accountID;
currentUserEmail = val.email;
currentUserAccountID = val.accountID;
isAnonymousUser = val.authTokenType === 'anonymousAccount';
},
});

Expand Down Expand Up @@ -2346,7 +2349,7 @@ function getParentReport(report) {
* @returns {Boolean}
*/
function shouldHideComposer(report, reportErrors) {
return isArchivedRoom(report) || !_.isEmpty(reportErrors) || !isAllowedToComment(report);
return isArchivedRoom(report) || !_.isEmpty(reportErrors) || !isAllowedToComment(report) || isAnonymousUser;
}

/**
Expand Down
34 changes: 20 additions & 14 deletions src/pages/home/report/ReportFooter.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import compose from '../../../libs/compose';
import ONYXKEYS from '../../../ONYXKEYS';
import withWindowDimensions, {windowDimensionsPropTypes} from '../../../components/withWindowDimensions';
import styles from '../../../styles/styles';
import variables from '../../../styles/variables';
import reportActionPropTypes from './reportActionPropTypes';
import reportPropTypes from '../../reportPropTypes';
import * as ReportUtils from '../../../libs/ReportUtils';
Expand Down Expand Up @@ -59,12 +60,21 @@ const defaultProps = {
function ReportFooter(props) {
const chatFooterStyles = {...styles.chatFooter, minHeight: !props.isOffline ? CONST.CHAT_FOOTER_MIN_HEIGHT : 0};
const isArchivedRoom = ReportUtils.isArchivedRoom(props.report);
const isAnonymousUser = Session.isAnonymousUser();

const isSmallSizeLayout = props.windowWidth - (props.isSmallScreenWidth ? 0 : variables.sideBarWidth) < variables.anonymousReportFooterBreakpoint;
const hideComposer = ReportUtils.shouldHideComposer(props.report, props.errors);

return (
<>
{(isArchivedRoom || hideComposer) && (
{hideComposer && (
<View style={[styles.chatFooter, props.isSmallScreenWidth ? styles.mb5 : null]}>
{isAnonymousUser && !isArchivedRoom && (
<AnonymousReportFooter
report={props.report}
isSmallSizeLayout={isSmallSizeLayout}
/>
)}
{isArchivedRoom && <ArchivedReportFooter report={props.report} />}
{!props.isSmallScreenWidth && (
<View style={styles.offlineIndicatorRow}>{hideComposer && <OfflineIndicator containerStyles={[styles.chatItemComposeSecondaryRow]} />}</View>
Expand All @@ -74,19 +84,15 @@ function ReportFooter(props) {
{!hideComposer && (props.shouldShowComposeInput || !props.isSmallScreenWidth) && (
<View style={[chatFooterStyles, props.isComposerFullSize && styles.chatFooterFullCompose]}>
<SwipeableView onSwipeDown={Keyboard.dismiss}>
{Session.isAnonymousUser() ? (
<AnonymousReportFooter report={props.report} />
) : (
<ReportActionCompose
onSubmit={props.onSubmitComment}
reportID={props.report.reportID.toString()}
reportActions={props.reportActions}
report={props.report}
pendingAction={props.pendingAction}
isComposerFullSize={props.isComposerFullSize}
disabled={props.shouldDisableCompose}
/>
)}
<ReportActionCompose
onSubmit={props.onSubmitComment}
reportID={props.report.reportID.toString()}
reportActions={props.reportActions}
report={props.report}
pendingAction={props.pendingAction}
isComposerFullSize={props.isComposerFullSize}
disabled={props.shouldDisableCompose}
/>
</SwipeableView>
</View>
)}
Expand Down
34 changes: 22 additions & 12 deletions src/styles/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -2218,31 +2218,41 @@ const styles = {
minWidth: 100,
},

anonymousRoomFooter: {
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
anonymousRoomFooter: (isSmallSizeLayout) => ({
flexDirection: isSmallSizeLayout ? 'column' : 'row',
...(!isSmallSizeLayout && {
alignItems: 'center',
justifyContent: 'space-between',
}),
padding: 20,
marginBottom: 20,
backgroundColor: themeColors.activeComponentBG,
flexWrap: 'wrap',
gap: 8,
backgroundColor: themeColors.sidebar,
borderRadius: variables.componentBorderRadiusLarge,
overflow: 'hidden',
},

}),
anonymousRoomFooterWordmarkAndLogoContainer: (isSmallSizeLayout) => ({
flexDirection: 'row',
alignItems: 'center',
...(isSmallSizeLayout && {
justifyContent: 'space-between',
marginTop: 16,
}),
}),
anonymousRoomFooterLogo: {
width: 88,
marginLeft: 0,
height: 20,
},

anonymousRoomFooterLogoTaglineText: {
fontFamily: fontFamily.EXP_NEUE,
fontSize: variables.fontSizeMedium,
color: themeColors.textLight,
},
signInButtonAvatar: {
width: 80,
},

anonymousRoomFooterSignInButton: {
width: 125,
width: 110,
},

roomHeaderAvatarSize: {
Expand Down
1 change: 1 addition & 0 deletions src/styles/variables.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export default {
popoverWidth: 375,
addPaymentPopoverTopSpacing: 8,
addPaymentPopoverRightSpacing: 13,
anonymousReportFooterBreakpoint: 650,

// The height of the empty list is 14px (2px for borders and 12px for vertical padding)
// This is calculated based on the values specified in the 'getGoogleListViewStyle' function of the 'StyleUtils' utility
Expand Down