-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Replace receipt #26508
Replace receipt #26508
Changes from all commits
d2f3e5f
6c96baf
c1bd0b1
3c2594a
3a69d70
8116a8e
f5234ac
6ea483c
eb50cd0
356f371
1c54e59
84ef3bd
2ac57b7
945d500
f4392a1
125117b
95fc8c2
23acf54
69ac668
24b38e6
43c08f5
435bb61
e735569
a1c8657
332a193
fda0cee
424ac34
1fc6c5a
164b129
b81a159
1a8f8f5
72eca6d
39236e3
35d51ab
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import React, {useState, useCallback} from 'react'; | ||
import React, {useState, useCallback, useRef} from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import {View, Animated, Keyboard} from 'react-native'; | ||
import Str from 'expensify-common/lib/str'; | ||
|
@@ -25,6 +25,10 @@ import HeaderGap from './HeaderGap'; | |
import SafeAreaConsumer from './SafeAreaConsumer'; | ||
import addEncryptedAuthTokenToURL from '../libs/addEncryptedAuthTokenToURL'; | ||
import reportPropTypes from '../pages/reportPropTypes'; | ||
import * as Expensicons from './Icon/Expensicons'; | ||
import useWindowDimensions from '../hooks/useWindowDimensions'; | ||
import Navigation from '../libs/Navigation/Navigation'; | ||
import ROUTES from '../ROUTES'; | ||
import useNativeDriver from '../libs/useNativeDriver'; | ||
|
||
/** | ||
|
@@ -94,6 +98,7 @@ const defaultProps = { | |
}; | ||
|
||
function AttachmentModal(props) { | ||
const onModalHideCallbackRef = useRef(null); | ||
const [isModalOpen, setIsModalOpen] = useState(props.defaultOpen); | ||
const [shouldLoadAttachment, setShouldLoadAttachment] = useState(false); | ||
const [isAttachmentInvalid, setIsAttachmentInvalid] = useState(false); | ||
|
@@ -106,6 +111,8 @@ function AttachmentModal(props) { | |
const [isConfirmButtonDisabled, setIsConfirmButtonDisabled] = useState(false); | ||
const [confirmButtonFadeAnimation] = useState(new Animated.Value(1)); | ||
const [shouldShowDownloadButton, setShouldShowDownloadButton] = React.useState(true); | ||
const {windowWidth} = useWindowDimensions(); | ||
|
||
const [file, setFile] = useState( | ||
props.originalFileName | ||
? { | ||
|
@@ -331,6 +338,10 @@ function AttachmentModal(props) { | |
}} | ||
onModalHide={(e) => { | ||
props.onModalHide(e); | ||
if (onModalHideCallbackRef.current) { | ||
onModalHideCallbackRef.current(); | ||
} | ||
|
||
setShouldLoadAttachment(false); | ||
}} | ||
propagateSwipe | ||
|
@@ -339,12 +350,30 @@ function AttachmentModal(props) { | |
<HeaderWithBackButton | ||
title={props.headerTitle || translate(isAttachmentReceipt ? 'common.receipt' : 'common.attachment')} | ||
shouldShowBorderBottom | ||
shouldShowDownloadButton={props.allowDownload && shouldShowDownloadButton} | ||
shouldShowDownloadButton={props.allowDownload && shouldShowDownloadButton && !isAttachmentReceipt} | ||
onDownloadButtonPress={() => downloadAttachment(source)} | ||
shouldShowCloseButton={!props.isSmallScreenWidth} | ||
shouldShowBackButton={props.isSmallScreenWidth} | ||
onBackButtonPress={closeModal} | ||
onCloseButtonPress={closeModal} | ||
shouldShowThreeDotsButton={isAttachmentReceipt} | ||
threeDotsAnchorPosition={styles.threeDotsPopoverOffsetAttachmentModal(windowWidth)} | ||
threeDotsMenuItems={[ | ||
{ | ||
icon: Expensicons.Camera, | ||
text: props.translate('common.replace'), | ||
onSelected: () => { | ||
onModalHideCallbackRef.current = () => Navigation.navigate(ROUTES.getEditRequestRoute(props.report.reportID, CONST.EDIT_REQUEST_FIELD.RECEIPT)); | ||
closeModal(); | ||
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 caused #27903 when navigating to the replace receipt screen not from within a tab navigator, i.e. whenever clicking from the three dots menu. |
||
}, | ||
}, | ||
{ | ||
icon: Expensicons.Download, | ||
text: props.translate('common.download'), | ||
onSelected: () => downloadAttachment(source), | ||
}, | ||
]} | ||
shouldOverlay | ||
/> | ||
<View style={styles.imageModalImageCenterContainer}> | ||
{!_.isEmpty(props.report) ? ( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import ScreenWrapper from '../components/ScreenWrapper'; | ||
import HeaderWithBackButton from '../components/HeaderWithBackButton'; | ||
import Navigation from '../libs/Navigation/Navigation'; | ||
import useLocalize from '../hooks/useLocalize'; | ||
import ReceiptSelector from './iou/ReceiptSelector'; | ||
import DragAndDropProvider from '../components/DragAndDrop/Provider'; | ||
|
||
const propTypes = { | ||
/** React Navigation route */ | ||
route: PropTypes.shape({ | ||
/** Params from the route */ | ||
params: PropTypes.shape({ | ||
/** The type of IOU report, i.e. bill, request, send */ | ||
iouType: PropTypes.string, | ||
|
||
/** The report ID of the IOU */ | ||
reportID: PropTypes.string, | ||
}), | ||
}).isRequired, | ||
|
||
/** The id of the transaction we're editing */ | ||
transactionID: PropTypes.string.isRequired, | ||
}; | ||
|
||
function EditRequestReceiptPage({route, transactionID}) { | ||
const {translate} = useLocalize(); | ||
|
||
return ( | ||
<ScreenWrapper | ||
includeSafeAreaPaddingBottom={false} | ||
shouldEnableMaxHeight | ||
> | ||
<HeaderWithBackButton | ||
title={translate('common.receipt')} | ||
onBackButtonPress={Navigation.goBack} | ||
/> | ||
<DragAndDropProvider> | ||
<ReceiptSelector | ||
route={route} | ||
transactionID={transactionID} | ||
/> | ||
</DragAndDropProvider> | ||
Comment on lines
+35
to
+44
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 causes an inconsistency issue here where the Green drag and drop area does not show in full-screen #28014 |
||
</ScreenWrapper> | ||
); | ||
} | ||
|
||
EditRequestReceiptPage.propTypes = propTypes; | ||
EditRequestReceiptPage.displayName = 'EditRequestReceiptPage'; | ||
|
||
export default EditRequestReceiptPage; |
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.
What does this do?