-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Show eReceipts for distance requests #27204
Merged
Merged
Changes from 21 commits
Commits
Show all changes
60 commits
Select commit
Hold shift + click to select a range
fabe55f
WIP render an eReceipt for distance requests
neil-marcellini a6b83fe
Render the receipt image
neil-marcellini 9d7538c
Style and clean up
neil-marcellini bffd20b
Merge branch 'main' into neil-distance-receipts
neil-marcellini 71689bd
Add amount and thumbnail image
neil-marcellini 8095338
Add merchant
neil-marcellini d9ddb6f
Display waypoints
neil-marcellini 71ff545
Remove unused import
neil-marcellini 215c03e
Style e receipt merchant text
neil-marcellini 90ad229
Style eReceipt waypoint titles
neil-marcellini c1aa7b3
Style eReceipt waypoint address
neil-marcellini 5bb7b9e
Add date text
neil-marcellini dd0fe7e
WIP add logo
neil-marcellini f69bf99
Add logo and guaranteed eReceipt
neil-marcellini 3a67ed4
Set up wrapping views with padding
neil-marcellini 74664ce
Fix lint issues / clean up
neil-marcellini 6e1440e
Add the eReceipt background
neil-marcellini f8ef144
The eReceipt is specific to distance requests
neil-marcellini ab4db97
Set up gap between main sections
neil-marcellini 0954367
Spacing and layout within sections
neil-marcellini 8b8afe9
Set width on eReceipt for large screens
neil-marcellini 8c28a58
Center eReceipt vertically on page
neil-marcellini 3382e90
Use colors directly since it's a specific purpose
neil-marcellini 16f3d79
Fix missing colors import
neil-marcellini 7aef125
Fix background color
neil-marcellini 00108d1
Make large eReceipts scrollable
neil-marcellini d2305c2
Fix center eReceipt vertically with scroll view
neil-marcellini 327109e
Add spanish translation
neil-marcellini 001799d
Align background with top of eReceipt
neil-marcellini 87c8457
Remove receipt image border for prettier loading
neil-marcellini 6b1983e
Merge branch 'main' into neil-distance-receipts
neil-marcellini d891e79
Fix distance request next button while offline
neil-marcellini 32d4091
Fix isDistanceRequest for optimistic transactions
neil-marcellini 54a25c4
Use placeholders for offline distance eReceipts
neil-marcellini bb6aa08
Merge branch 'main' into neil-distance-receipts
neil-marcellini 5c5f717
Use withOnyx for transaction vs deprecated utils
neil-marcellini db6e4da
Update comment
neil-marcellini 7877d5e
Fix and simplify transaction access
neil-marcellini b2c3f9e
Fix prop type
neil-marcellini 6963757
Fix online and offline transaction amount
neil-marcellini 1d3a8b9
Load thumbnail only when image source is ready
neil-marcellini 5545564
Ensure waypoints are ordered properly for eReceipt
neil-marcellini b62df64
Set the rate to TBD when it's unavailable
neil-marcellini 25d66cc
Fix crash / prop types with default receipt source
neil-marcellini 2d653b8
Fix eReceipt background on Android
neil-marcellini 1e86e51
Fix linter
neil-marcellini 058f38e
Prevent top of merchant text being cut off
neil-marcellini 0a04398
Merge branch 'main' into neil-distance-receipts
neil-marcellini 3bd0c26
Line height can be larger by convention
neil-marcellini 50349b2
Show scroll bar at the full width of the modal
neil-marcellini 0ae77b6
Merge branch 'main' into neil-distance-receipts
neil-marcellini d28fcfc
Clean up after review feedback
neil-marcellini 93687c9
Show distance amount as TBD on request preview
neil-marcellini 94fc6d7
Use TBD amount for distance request view
neil-marcellini d374539
Remove cash from distance amount field description
neil-marcellini 70ead50
Remove possibly undefined waypoints
neil-marcellini 712dc86
Merge branch 'main' into neil-distance-receipts
neil-marcellini 4d49405
Merge branch 'main' into neil-distance-receipts
neil-marcellini 8dedc7a
Merge branch 'main' into neil-distance-receipts
neil-marcellini 4e23ab4
Fix duplicate translation key after merge
neil-marcellini File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import React from 'react'; | ||
import {View} from 'react-native'; | ||
import lodashGet from 'lodash/get'; | ||
import _ from 'underscore'; | ||
import Text from './Text'; | ||
import styles from '../styles/styles'; | ||
import transactionPropTypes from './transactionPropTypes'; | ||
import * as ReceiptUtils from '../libs/ReceiptUtils'; | ||
import * as ReportUtils from '../libs/ReportUtils'; | ||
import * as CurrencyUtils from '../libs/CurrencyUtils'; | ||
import * as TransactionUtils from '../libs/TransactionUtils'; | ||
import tryResolveUrlFromApiRoot from '../libs/tryResolveUrlFromApiRoot'; | ||
import ThumbnailImage from './ThumbnailImage'; | ||
import useLocalize from '../hooks/useLocalize'; | ||
import Icon from './Icon'; | ||
import themeColors from '../styles/themes/default'; | ||
import * as Expensicons from './Icon/Expensicons'; | ||
import EReceiptBackground from '../../assets/images/eReceipt_background.svg'; | ||
|
||
const propTypes = { | ||
/** The transaction for the eReceipt */ | ||
transaction: transactionPropTypes, | ||
}; | ||
|
||
const defaultProps = { | ||
transaction: {}, | ||
}; | ||
|
||
function DistanceEReceipt({transaction}) { | ||
const {translate} = useLocalize(); | ||
const {thumbnail} = ReceiptUtils.getThumbnailAndImageURIs(transaction.receipt.source, transaction.filename); | ||
neil-marcellini marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const {amount: transactionAmount, currency: transactionCurrency, merchant: transactionMerchant, created: transactionDate} = ReportUtils.getTransactionDetails(transaction); | ||
const formattedTransactionAmount = CurrencyUtils.convertToDisplayString(transactionAmount, transactionCurrency); | ||
const thumbnailSource = tryResolveUrlFromApiRoot(thumbnail || ''); | ||
const waypoints = lodashGet(transaction, 'comment.waypoints', {}); | ||
return ( | ||
<View style={[styles.ph5, styles.pv5, styles.flex1, styles.alignItemsCenter]}> | ||
<View style={styles.eReceiptPanel}> | ||
<View style={styles.eReceiptBackgroundContainer}> | ||
<EReceiptBackground | ||
style={styles.eReceiptBackground} | ||
pointerEvents="none" | ||
/> | ||
</View> | ||
<View style={[styles.moneyRequestViewImage, styles.mh0, styles.mt0, styles.mb5]}> | ||
<ThumbnailImage | ||
previewSourceURL={thumbnailSource} | ||
style={[styles.w100, styles.h100]} | ||
isAuthTokenRequired | ||
shouldDynamicallyResize={false} | ||
/> | ||
</View> | ||
<View style={[styles.mb10, styles.gap5, styles.ph2, styles.flexColumn, styles.alignItemsCenter]}> | ||
<Text style={styles.eReceiptAmount}>{formattedTransactionAmount}</Text> | ||
<Text style={styles.eReceiptMerchant}>{transactionMerchant}</Text> | ||
</View> | ||
<View style={[styles.mb10, styles.gap5, styles.ph2]}> | ||
{_.map(waypoints, (waypoint, key) => { | ||
const index = TransactionUtils.getWaypointIndex(key); | ||
let descriptionKey = 'distance.waypointDescription.'; | ||
if (index === 0) { | ||
descriptionKey += 'start'; | ||
} else if (index === _.size(waypoints) - 1) { | ||
descriptionKey += 'finish'; | ||
} else { | ||
descriptionKey += 'stop'; | ||
} | ||
return ( | ||
<View | ||
style={styles.gap1} | ||
key={key} | ||
> | ||
<Text style={styles.eReceiptWaypointTitle}>{translate(descriptionKey)}</Text> | ||
<Text style={styles.eReceiptWaypointAddress}>{waypoint.address || ''}</Text> | ||
</View> | ||
); | ||
})} | ||
<View style={styles.gap1}> | ||
<Text style={styles.eReceiptWaypointTitle}>{translate('common.date')}</Text> | ||
<Text style={styles.eReceiptWaypointAddress}>{transactionDate}</Text> | ||
</View> | ||
</View> | ||
<View style={[styles.ph2, styles.flexRow, styles.justifyContentBetween, styles.alignItemsCenter]}> | ||
<Icon | ||
width={86} | ||
height={19.25} | ||
fill={themeColors.textBrand} | ||
src={Expensicons.ExpensifyWordmark} | ||
/> | ||
<Text style={styles.eReceiptGuaranteed}>{translate('eReceipt.guaranteed')}</Text> | ||
</View> | ||
</View> | ||
</View> | ||
); | ||
} | ||
|
||
export default DistanceEReceipt; | ||
DistanceEReceipt.displayName = 'DistanceEReceipt'; | ||
DistanceEReceipt.propTypes = propTypes; | ||
DistanceEReceipt.defaultProps = defaultProps; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3553,6 +3553,69 @@ const styles = (theme) => ({ | |
lineHeight: variables.lineHeightXXLarge, | ||
}, | ||
|
||
eReceiptAmount: { | ||
...headlineFont, | ||
fontSize: variables.fontSizeXXXLarge, | ||
lineHeight: variables.lineHeightXXXLarge, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line caused an edge case regression in #29616; when device font size is set to the minimum, the amount in the e-receipt is cut off. |
||
color: theme.textBrand, | ||
}, | ||
|
||
eReceiptMerchant: { | ||
fontFamily: fontFamily.EXP_NEUE, | ||
fontSize: variables.fontSizeXLarge, | ||
lineHeight: variables.lineHeightXLarge, | ||
color: theme.text, | ||
}, | ||
|
||
eReceiptWaypointTitle: { | ||
fontFamily: fontFamily.EXP_NEUE, | ||
fontSize: variables.fontSizeSmall, | ||
lineHeight: variables.lineHeightSmall, | ||
color: theme.textBrand, | ||
}, | ||
|
||
eReceiptWaypointAddress: { | ||
fontFamily: fontFamily.MONOSPACE, | ||
fontSize: variables.fontSizeNormal, | ||
lineHeight: variables.lineHeightNormal, | ||
color: theme.textColorfulBackground, | ||
}, | ||
|
||
eReceiptGuaranteed: { | ||
fontFamily: fontFamily.MONOSPACE, | ||
fontSize: variables.fontSizeSmall, | ||
lineHeight: variables.lineHeightSmall, | ||
color: theme.textColorfulBackground, | ||
}, | ||
|
||
eReceiptBackgroundContainer: { | ||
position: 'absolute', | ||
top: 0, | ||
left: 0, | ||
right: 0, | ||
bottom: 0, | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
}, | ||
|
||
eReceiptBackground: { | ||
...sizing.w100, | ||
position: 'absolute', | ||
top: 0, | ||
left: 0, | ||
right: 0, | ||
bottom: 0, | ||
minHeight: 540, | ||
}, | ||
|
||
eReceiptPanel: { | ||
...spacing.p5, | ||
...spacing.pb8, | ||
backgroundColor: theme.panelBackground, | ||
borderRadius: 20, | ||
width: 335, | ||
}, | ||
|
||
loginHeroBody: { | ||
fontFamily: fontFamily.EXP_NEUE, | ||
fontSize: variables.fontSizeSignInHeroBody, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hey @neil-marcellini could you link me to this asset?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can download it here 🙂 https://github.com/Expensify/App/blob/0a04398d12f0d68873a8fafd95227d08de8f5be3/assets/images/eReceipt_background.svg