Skip to content

Commit

Permalink
Changes Complete
Browse files Browse the repository at this point in the history
  • Loading branch information
kaushiktd committed Nov 10, 2023
1 parent c1d3a83 commit e74ca7a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 37 deletions.
66 changes: 31 additions & 35 deletions src/components/ReportActionItem/ReportActionItemImage.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,24 @@ import PropTypes from 'prop-types';
import React from 'react';
import {View} from 'react-native';
import _ from 'underscore';
import EReceiptThumbnail from '@components/EReceiptThumbnail';
import Image from '@components/Image';
import PressableWithoutFocus from '@components/Pressable/PressableWithoutFocus';
import {ShowContextMenuContext} from '@components/ShowContextMenuContext';
import ThumbnailImage from '@components/ThumbnailImage';
import transactionPropTypes from '@components/transactionPropTypes';
import useLocalize from '@hooks/useLocalize';
import Navigation from '@libs/Navigation/Navigation';
import * as TransactionUtils from '@libs/TransactionUtils';
import tryResolveUrlFromApiRoot from '@libs/tryResolveUrlFromApiRoot';
import styles from '@styles/styles';
import CONST from '@src/CONST';
import ROUTES from '@src/ROUTES';
import EReceiptThumbnail from '../../components/EReceiptThumbnail';
import Image from '../../components/Image';
import PressableWithoutFocus from '../../components/Pressable/PressableWithoutFocus';
import {ShowContextMenuContext} from '../../components/ShowContextMenuContext';
import ThumbnailImage from '../../components/ThumbnailImage';
import transactionPropTypes from '../../components/transactionPropTypes';
import useLocalize from '../../hooks/useLocalize';
import Navigation from '../../libs/Navigation/Navigation';
import * as TransactionUtils from '../../libs/TransactionUtils';
import tryResolveUrlFromApiRoot from '../../libs/tryResolveUrlFromApiRoot';
import styles from '../../styles/styles';
import CONST from '../../../src/CONST';
import ROUTES from '../../../src/ROUTES';
import Icon from '../../components/Icon';
import * as StyleUtils from '@styles/StyleUtils';
import variables from '@styles/variables';
import variables from '../../styles/variables';
import * as Expensicons from '../../components/Icon/Expensicons';
import colors from '../../styles/colors';
import useNetwork from '@hooks/useNetwork';
import useNetwork from '../../hooks/useNetwork';

const propTypes = {
/** thumbnail URI for the image */
Expand Down Expand Up @@ -56,33 +55,30 @@ const defaultProps = {
* and optional preview modal as well.
*/

function ReportActionItemImage({thumbnail, image, enablePreviewModal, transaction}) {
function ReportActionItemImage({ thumbnail, image, enablePreviewModal, transaction, iconFill, fallbackIcon }) {
const {translate} = useLocalize();
const imageSource = tryResolveUrlFromApiRoot(image || '');
const thumbnailSource = tryResolveUrlFromApiRoot(thumbnail || '');
const isEReceipt = !_.isEmpty(transaction) && TransactionUtils.hasEReceipt(transaction);
const {isOffline} = useNetwork();
let heightStyle = StyleUtils.getHeight(variables.iconImageHeight);

let receiptImageComponent;

if (isEReceipt) {
if (isOffline) {
receiptImageComponent = (
<Icon
src={props.fallbackIcon}
fill={props.iconFill}
height={heightStyle.height}
width={heightStyle.height}
/>
);
} else {
receiptImageComponent = (
<View style={[styles.w100, styles.h100]}>
<EReceiptThumbnail transactionID={transaction.transactionID} />
</View>
);
}
if (isOffline) {
receiptImageComponent = (
<Icon
src={fallbackIcon}
fill={iconFill}
height={variables.eReceiptIconHeightMedium}
width={variables.eReceiptIconWidthMedium}
/>
);
} else if (isEReceipt) {
receiptImageComponent = (
<View style={[styles.w100, styles.h100]}>
<EReceiptThumbnail transactionID={transaction.transactionID} />
</View>
);
} else if (thumbnail) {
receiptImageComponent = (
<ThumbnailImage
Expand Down
3 changes: 1 addition & 2 deletions src/styles/variables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,5 @@ export default {

cardPreviewHeight: 148,
cardPreviewWidth: 235,
cardNameWidth: 156,
iconImageHeight:112,
cardNameWidth: 156
} as const;

0 comments on commit e74ca7a

Please sign in to comment.