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

feat(26270): Add Skeleton UI for Money Requests #26613

Merged
merged 12 commits into from
Sep 4, 2023
40 changes: 40 additions & 0 deletions src/components/MoneyRequestSkeletonView.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import React from 'react';
import {Rect} from 'react-native-svg';
import SkeletonViewContentLoader from 'react-content-loader/native';
import variables from '../styles/variables';
import themeColors from '../styles/themes/default';
import styles from '../styles/styles';

function MoneyRequestSkeletonView() {
return (
<SkeletonViewContentLoader
animate
width={styles.w100.width}
height={variables.moneyRequestSkeletonHeight}
backgroundColor={themeColors.borderLighter}
foregroundColor={themeColors.border}
>
<Rect
x="16"
y="20"
width="40"
height="8"
/>
<Rect
x="16"
y="46"
width="120"
height="20"
/>
<Rect
x="16"
y="78"
width="80"
height="8"
/>
</SkeletonViewContentLoader>
);
}

MoneyRequestSkeletonView.displayName = 'MoneyRequestSkeletonView';
export default MoneyRequestSkeletonView;
123 changes: 64 additions & 59 deletions src/components/ReportActionItem/MoneyRequestPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import * as ReceiptUtils from '../../libs/ReceiptUtils';
import ReportActionItemImages from './ReportActionItemImages';
import transactionPropTypes from '../transactionPropTypes';
import colors from '../../styles/colors';
import MoneyRequestSkeletonView from '../MoneyRequestSkeletonView';

const propTypes = {
/** The active IOUReport, used for Onyx subscription */
Expand Down Expand Up @@ -234,77 +235,81 @@ function MoneyRequestPreview(props) {
isHovered={isScanning}
/>
)}
<View style={styles.moneyRequestPreviewBoxText}>
mananjadhav marked this conversation as resolved.
Show resolved Hide resolved
<View style={[styles.flexRow]}>
<View style={[styles.flex1, styles.flexRow, styles.alignItemsCenter]}>
<Text style={[styles.textLabelSupporting, styles.mb1, styles.lh20]}>{getPreviewHeaderText()}</Text>
{Boolean(getSettledMessage()) && (
<>
<Icon
src={Expensicons.DotIndicator}
width={4}
height={4}
additionalStyles={[styles.mr1, styles.ml1]}
/>
<Text style={[styles.textLabelSupporting, styles.mb1, styles.lh20]}>{getSettledMessage()}</Text>
</>
{_.isEmpty(props.transaction) ? (
Copy link
Contributor

@0xmiros 0xmiros Oct 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This caused regression of showing skeleton forever when delete money request offline - #26939
Because transaction data is also deleted optimistically.

<MoneyRequestSkeletonView />
) : (
<View style={styles.moneyRequestPreviewBoxText}>
<View style={[styles.flexRow]}>
<View style={[styles.flex1, styles.flexRow, styles.alignItemsCenter]}>
<Text style={[styles.textLabelSupporting, styles.mb1, styles.lh20]}>{getPreviewHeaderText()}</Text>
{Boolean(getSettledMessage()) && (
<>
<Icon
src={Expensicons.DotIndicator}
width={4}
height={4}
additionalStyles={[styles.mr1, styles.ml1]}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/>
<Text style={[styles.textLabelSupporting, styles.mb1, styles.lh20]}>{getSettledMessage()}</Text>
</>
)}
</View>
{hasFieldErrors && (
<Icon
src={Expensicons.DotIndicator}
fill={colors.red}
/>
)}
</View>
{hasFieldErrors && (
<Icon
src={Expensicons.DotIndicator}
fill={colors.red}
/>
)}
</View>
<View style={[styles.flexRow]}>
<View style={[styles.flex1, styles.flexRow, styles.alignItemsCenter]}>
<Text style={styles.textHeadline}>{getDisplayAmountText()}</Text>
{ReportUtils.isSettled(props.iouReport.reportID) && !props.isBillSplit && (
<View style={styles.defaultCheckmarkWrapper}>
<Icon
src={Expensicons.Checkmark}
fill={themeColors.iconSuccessFill}
<View style={[styles.flexRow]}>
<View style={[styles.flex1, styles.flexRow, styles.alignItemsCenter]}>
<Text style={styles.textHeadline}>{getDisplayAmountText()}</Text>
{ReportUtils.isSettled(props.iouReport.reportID) && !props.isBillSplit && (
<View style={styles.defaultCheckmarkWrapper}>
<Icon
src={Expensicons.Checkmark}
fill={themeColors.iconSuccessFill}
/>
</View>
)}
</View>
{props.isBillSplit && (
<View style={styles.moneyRequestPreviewBoxAvatar}>
<MultipleAvatars
icons={participantAvatars}
shouldStackHorizontally
size="small"
isHovered={props.isHovered}
shouldUseCardBackground
/>
</View>
)}
</View>
{props.isBillSplit && (
<View style={styles.moneyRequestPreviewBoxAvatar}>
<MultipleAvatars
icons={participantAvatars}
shouldStackHorizontally
size="small"
isHovered={props.isHovered}
shouldUseCardBackground
/>
{shouldShowMerchant && (
<View style={[styles.flexRow]}>
<Text style={[styles.textLabelSupporting, styles.mb1, styles.lh20, styles.breakWord]}>{requestMerchant}</Text>
</View>
)}
</View>
{shouldShowMerchant && (
<View style={[styles.flexRow]}>
<Text style={[styles.textLabelSupporting, styles.mb1, styles.lh20, styles.breakWord]}>{requestMerchant}</Text>
</View>
)}
<View style={[styles.flexRow]}>
<View style={[styles.flex1]}>
{!isCurrentUserManager && props.shouldShowPendingConversionMessage && (
<Text style={[styles.textLabel, styles.colorMuted, styles.mt1]}>{props.translate('iou.pendingConversionMessage')}</Text>
<View style={[styles.flex1]}>
{!isCurrentUserManager && props.shouldShowPendingConversionMessage && (
<Text style={[styles.textLabel, styles.colorMuted, styles.mt1]}>{props.translate('iou.pendingConversionMessage')}</Text>
)}
{shouldShowDescription && <Text style={[styles.mt1, styles.colorMuted]}>{description}</Text>}
</View>
{props.isBillSplit && !_.isEmpty(participantAccountIDs) && (
<Text style={[styles.textLabel, styles.colorMuted, styles.ml1]}>
{props.translate('iou.amountEach', {
amount: CurrencyUtils.convertToDisplayString(
IOUUtils.calculateAmount(isPolicyExpenseChat ? 1 : participantAccountIDs.length - 1, requestAmount, requestCurrency),
requestCurrency,
),
})}
</Text>
)}
{shouldShowDescription && <Text style={[styles.mt1, styles.colorMuted]}>{description}</Text>}
</View>
{props.isBillSplit && !_.isEmpty(participantAccountIDs) && (
<Text style={[styles.textLabel, styles.colorMuted, styles.ml1]}>
{props.translate('iou.amountEach', {
amount: CurrencyUtils.convertToDisplayString(
IOUUtils.calculateAmount(isPolicyExpenseChat ? 1 : participantAccountIDs.length - 1, requestAmount, requestCurrency),
requestCurrency,
),
})}
</Text>
)}
</View>
</View>
)}
</View>
</OfflineWithFeedback>
</View>
Expand Down
2 changes: 2 additions & 0 deletions src/styles/variables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,6 @@ export default {
qrShareHorizontalPadding: 32,

baseMenuItemHeight: 64,

moneyRequestSkeletonHeight: 107,
} as const;
Loading