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
3 changes: 2 additions & 1 deletion src/components/MoneyRequestConfirmationList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ function MoneyRequestConfirmationList({

const sections = useConfirmationSections({
isTypeSplit,
isTypeInvoice,
shouldHideToSection,
shouldForceTopEmptySections,
participantRowErrors,
Expand Down Expand Up @@ -509,7 +510,7 @@ function MoneyRequestConfirmationList({
const selectionListStyle = {
containerStyle: [styles.flexBasisAuto],
contentContainerStyle: isCompactMode ? [styles.flexGrow1] : undefined,
listFooterContentStyle: isCompactMode ? [styles.flex1, styles.mv3] : [styles.mv3],
listFooterContentStyle: isCompactMode ? [styles.flex1, styles.mb3] : [styles.mb3],
};

const footerContent = isReadOnly ? undefined : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ type UseConfirmationSectionsParams = {
/** Whether the current IOU type is split */
isTypeSplit: boolean;

/** Whether the current IOU type is invoice (keeps the "To" header, which pairs with the invoice "Send from" field) */
isTypeInvoice?: boolean;

/** Whether the "to" section should be hidden (used when adding directly to a report) */
shouldHideToSection: boolean;

Expand Down Expand Up @@ -55,6 +58,7 @@ type UseConfirmationSectionsParams = {
*/
function useConfirmationSections({
isTypeSplit,
isTypeInvoice = false,
shouldHideToSection,
shouldForceTopEmptySections = false,
participantRowErrors,
Expand Down Expand Up @@ -104,7 +108,7 @@ function useConfirmationSections({
];

options.push({
title: selectedParticipants.length > 0 ? translate('common.to') : undefined,
title: isTypeInvoice && selectedParticipants.length > 0 ? translate('common.to') : undefined,
data: participantRows,
sectionIndex: 0,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ function ReceiptSection({
}
Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_SCAN.getRoute(CONST.IOU.ACTION.CREATE, iouType, transactionID, reportID, Navigation.getActiveRoute()));
}}
style={[compact.isCompactMode ? undefined : styles.mv3, compact.isCompactMode && compact.compactReceiptStyle ? compact.compactReceiptStyle : styles.moneyRequestViewImage]}
isCompact={!compact.isCompactMode}
style={[compact.isCompactMode ? undefined : styles.mt2, compact.isCompactMode && compact.compactReceiptStyle ? compact.compactReceiptStyle : undefined]}
/>
);
}
Expand Down
92 changes: 57 additions & 35 deletions src/components/ReceiptEmptyState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type {FileObject} from '@src/types/utils/Attachment';

import type {StyleProp, ViewStyle} from 'react-native';

import React, {useEffect, useRef} from 'react';
import React, {useEffect, useRef, useState} from 'react';
import {View} from 'react-native';
import Svg, {Path} from 'react-native-svg';

Expand All @@ -37,6 +37,9 @@ type ReceiptEmptyStateProps = {
/** Whether the receipt empty state should extend to the full height of the container. */
shouldUseFullHeight?: boolean;

/** Whether to render the small banner layout (icon + label in a row) instead of the full-height box */
isCompact?: boolean;

style?: StyleProp<ViewStyle>;

/** Callback to be called when the image loads */
Expand Down Expand Up @@ -75,6 +78,7 @@ function ReceiptEmptyState({
isThumbnail = false,
isInMoneyRequestView = false,
shouldUseFullHeight = false,
isCompact = false,
style,
onLoad,
isDisplayedInWideRHP = false,
Expand All @@ -84,20 +88,23 @@ function ReceiptEmptyState({
const {translate} = useLocalize();
const theme = useTheme();
const isLoadedRef = useRef(false);
const icons = useMemoizedLazyExpensifyIcons(['Receipt']);
const [isHovered, setIsHovered] = useState(false);
const icons = useMemoizedLazyExpensifyIcons(['Receipt', 'ReceiptPlus']);

const {validateFiles, PDFValidationComponent, ErrorModal} = useFilesValidation(setReceiptFile);

const Wrapper = onPress ? PressableWithoutFeedback : View;
const containerStyle = [
styles.alignItemsCenter,
styles.justifyContentCenter,
styles.moneyRequestViewImage,
isDisplayedInWideRHP && !disabled && styles.pb5,
isThumbnail && !isInMoneyRequestView ? styles.moneyRequestAttachReceiptThumbnail : styles.moneyRequestAttachReceipt,
shouldUseFullHeight && styles.receiptEmptyStateFullHeight,
style,
];
const containerStyle = isCompact
? [styles.alignItemsCenter, styles.justifyContentCenter, styles.receiptEmptyStateCompact, styles.moneyRequestAttachReceipt, style]
: [
styles.alignItemsCenter,
styles.justifyContentCenter,
styles.moneyRequestViewImage,
isDisplayedInWideRHP && !disabled && styles.pb5,
isThumbnail && !isInMoneyRequestView ? styles.moneyRequestAttachReceiptThumbnail : styles.moneyRequestAttachReceipt,
shouldUseFullHeight && styles.receiptEmptyStateFullHeight,
style,
];

useEffect(() => {
if (isLoadedRef.current) {
Expand All @@ -124,37 +131,52 @@ function ReceiptEmptyState({
}}
disabled={disabled}
disabledStyle={styles.cursorDefault}
hoverStyle={onPress && isCompact ? styles.hoveredComponentBG : undefined}
onHoverIn={onPress && isCompact ? () => setIsHovered(true) : undefined}
onHoverOut={onPress && isCompact ? () => setIsHovered(false) : undefined}
style={containerStyle}
>
{PDFValidationComponent}
{ErrorModal}
<View style={[styles.flex1, styles.justifyContentCenter, styles.alignItemsCenter]}>
<View style={[styles.alignItemsCenter, styles.justifyContentCenter]}>
<View style={styles.pRelative}>
<Icon
fill={theme.border}
src={icons.Receipt}
width={variables.eReceiptEmptyIconWidth}
height={variables.eReceiptEmptyIconWidth}
/>
{!isThumbnail && (
<View style={[styles.moneyRequestAttachReceiptThumbnailIcon, {width: variables.avatarSizeSmall, height: variables.avatarSizeSmall}]}>
<ReceiptPlaceholderPlusIcon
circleFill={theme.success}
plusFill={theme.receiptPlaceholderPlus}
size={variables.avatarSizeSmall}
/>
</View>
{isCompact ? (
Comment thread
emkhalid marked this conversation as resolved.
<View style={[styles.flexRow, styles.justifyContentCenter, styles.alignItemsCenter, styles.gap2]}>
<Icon
src={icons.ReceiptPlus}
fill={isHovered ? theme.success : theme.icon}
width={variables.iconSizeNormal}
height={variables.iconSizeNormal}
/>
<Text style={styles.textStrong}>{translate('dropzone.addReceipt')}</Text>
</View>
) : (
<View style={[styles.flex1, styles.justifyContentCenter, styles.alignItemsCenter]}>
<View style={[styles.alignItemsCenter, styles.justifyContentCenter]}>
<View style={styles.pRelative}>
<Icon
fill={theme.border}
src={icons.Receipt}
width={variables.eReceiptEmptyIconWidth}
height={variables.eReceiptEmptyIconWidth}
/>
{!isThumbnail && (
<View style={[styles.moneyRequestAttachReceiptThumbnailIcon, {width: variables.avatarSizeSmall, height: variables.avatarSizeSmall}]}>
<ReceiptPlaceholderPlusIcon
circleFill={theme.success}
plusFill={theme.receiptPlaceholderPlus}
size={variables.avatarSizeSmall}
/>
</View>
)}
</View>
{!isThumbnail && isDisplayedInWideRHP && (
<>
<Text style={[styles.textHeadline, styles.mt4]}>{translate('receipt.addAReceipt.phrase1')}</Text>
<Text style={[styles.textSupporting, styles.textNormal]}>{translate('receipt.addAReceipt.phrase2')}</Text>
</>
)}
</View>
{!isThumbnail && isDisplayedInWideRHP && (
<>
<Text style={[styles.textHeadline, styles.mt4]}>{translate('receipt.addAReceipt.phrase1')}</Text>
<Text style={[styles.textSupporting, styles.textNormal]}>{translate('receipt.addAReceipt.phrase2')}</Text>
</>
)}
</View>
</View>
)}
{isDisplayedInWideRHP && !disabled && <ReceiptAlternativeMethods />}
</Wrapper>
)}
Expand Down
8 changes: 8 additions & 0 deletions src/styles/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4957,6 +4957,14 @@ const staticStyles = (theme: ThemeColors) =>

receiptEmptyStateFullHeight: {height: '100%', borderRadius: 12},

receiptEmptyStateCompact: {
...spacing.mh4,
overflow: 'hidden',
borderRadius: variables.componentBorderRadiusNormal,
height: 52,
maxWidth: '100%',
},

moneyRequestAttachReceiptThumbnailIcon: {
position: 'absolute',
bottom: -4,
Expand Down
Loading