-
Notifications
You must be signed in to change notification settings - Fork 4k
Create super wide RHP modal to display expense reports when accessed via Reports page or report previews #73731
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
Changes from all commits
e7bbab5
11f5d94
017f134
0f1fb88
40b8a9e
addada0
1bbf882
80d917a
7a05cf8
db1f6a2
77ea3cf
fc7a4c2
838456e
8c773cd
fb1000f
f8d1801
0838583
5261d34
00c8d0f
bc0e137
d3d3e8d
1047783
d895eae
c017a39
bd95c58
37701fb
eb6c8ed
efa43f0
2f8ec7c
fbb995c
10114db
eb17e49
1c1fdaa
fbee6db
df9b81d
dc38b79
521ae1a
dba4c2b
ce426e5
8713c06
ce181b3
3d9713b
9bd91b7
011514c
5f377cc
fa43422
06ac45a
f3bed80
fc4ad27
bcbf94c
69a2daa
a0ff628
2ba0f03
30471d0
f047bc8
6f35792
b83a8b2
eddc2e9
a1b283b
4de7f3e
e1286e6
e09233c
945caf1
d04fa90
57c2cde
597a3d6
14c29dd
e9dbe5a
980b84f
ade17a8
0975fbe
a1864bd
b73f655
559ffbc
d9f30dc
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,18 +1,23 @@ | ||
| import {PortalHost} from '@gorhom/portal'; | ||
| import React, {useCallback, useMemo} from 'react'; | ||
| import {InteractionManager, View} from 'react-native'; | ||
| // We use Animated for all functionality related to wide RHP to make it easier | ||
| // to interact with react-navigation components (e.g., CardContainer, interpolator), which also use Animated. | ||
| // eslint-disable-next-line no-restricted-imports | ||
| import {Animated, InteractionManager, ScrollView, View} from 'react-native'; | ||
| import type {OnyxEntry} from 'react-native-onyx'; | ||
| import HeaderGap from '@components/HeaderGap'; | ||
| import MoneyReportHeader from '@components/MoneyReportHeader'; | ||
| import MoneyRequestHeader from '@components/MoneyRequestHeader'; | ||
| import OfflineWithFeedback from '@components/OfflineWithFeedback'; | ||
| import MoneyRequestReceiptView from '@components/ReportActionItem/MoneyRequestReceiptView'; | ||
| import ReportActionsSkeletonView from '@components/ReportActionsSkeletonView'; | ||
| import ReportHeaderSkeletonView from '@components/ReportHeaderSkeletonView'; | ||
| import useNetwork from '@hooks/useNetwork'; | ||
| import useNewTransactions from '@hooks/useNewTransactions'; | ||
| import useOnyx from '@hooks/useOnyx'; | ||
| import usePaginatedReportActions from '@hooks/usePaginatedReportActions'; | ||
| import useParentReportAction from '@hooks/useParentReportAction'; | ||
| import useResponsiveLayout from '@hooks/useResponsiveLayout'; | ||
| import useThemeStyles from '@hooks/useThemeStyles'; | ||
| import useTransactionsAndViolationsForReport from '@hooks/useTransactionsAndViolationsForReport'; | ||
| import {removeFailedReport} from '@libs/actions/Report'; | ||
|
|
@@ -56,6 +61,16 @@ function goBackFromSearchMoneyRequest() { | |
| const rootState = navigationRef.getRootState(); | ||
| const lastRoute = rootState.routes.at(-1); | ||
|
|
||
| if (!lastRoute) { | ||
| Log.hmmm('[goBackFromSearchMoneyRequest()] No last route found in root state.'); | ||
| return; | ||
| } | ||
|
|
||
| if (lastRoute?.name === NAVIGATORS.RIGHT_MODAL_NAVIGATOR) { | ||
| Navigation.goBack(); | ||
| return; | ||
| } | ||
|
|
||
| if (lastRoute?.name !== NAVIGATORS.SEARCH_FULLSCREEN_NAVIGATOR) { | ||
| Log.hmmm('[goBackFromSearchMoneyRequest()] goBackFromSearchMoneyRequest was called from a different navigator than SearchFullscreenNavigator.'); | ||
| return; | ||
|
|
@@ -84,6 +99,10 @@ function MoneyRequestReportView({report, policy, reportMetadata, shouldDisplayRe | |
| const styles = useThemeStyles(); | ||
| const {isOffline} = useNetwork(); | ||
|
|
||
| // eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth | ||
| const {isSmallScreenWidth} = useResponsiveLayout(); | ||
|
|
||
| const [allReports] = useOnyx(ONYXKEYS.COLLECTION.REPORT, {canBeMissing: false}); | ||
| const reportID = report?.reportID; | ||
| const [isLoadingApp] = useOnyx(ONYXKEYS.IS_LOADING_APP, {canBeMissing: true}); | ||
| const [isComposerFullSize = false] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_IS_COMPOSER_FULL_SIZE}${reportID}`, {canBeMissing: true}); | ||
|
|
@@ -129,6 +148,9 @@ function MoneyRequestReportView({report, policy, reportMetadata, shouldDisplayRe | |
| const isEmptyTransactionReport = visibleTransactions && visibleTransactions.length === 0 && transactionThreadReportID === undefined; | ||
| const shouldDisplayMoneyRequestActionsList = !!isEmptyTransactionReport || shouldDisplayReportTableView(report, visibleTransactions ?? []); | ||
|
|
||
| const [transactionThreadReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${transactionThreadReportID}`, {canBeMissing: true}); | ||
| const shouldShowWideRHPReceipt = visibleTransactions.length === 1 && !isSmallScreenWidth && !!transactionThreadReport; | ||
|
|
||
| const reportHeaderView = useMemo( | ||
| () => | ||
| isTransactionThreadView ? ( | ||
|
|
@@ -211,47 +233,61 @@ function MoneyRequestReportView({report, policy, reportMetadata, shouldDisplayRe | |
| > | ||
| <HeaderGap /> | ||
| {reportHeaderView} | ||
| <View style={[styles.overflowHidden, styles.justifyContentEnd, styles.flex1]}> | ||
| {shouldDisplayMoneyRequestActionsList ? ( | ||
| <MoneyRequestReportActionsList | ||
| report={report} | ||
| policy={policy} | ||
| transactions={visibleTransactions} | ||
| hasPendingDeletionTransaction={hasPendingDeletionTransaction} | ||
| newTransactions={newTransactions} | ||
| reportActions={reportActions} | ||
| violations={allReportViolations} | ||
| hasOlderActions={hasOlderActions} | ||
| hasNewerActions={hasNewerActions} | ||
| showReportActionsLoadingState={isLoadingInitialReportActions && !reportMetadata?.hasOnceLoadedReportActions} | ||
| /> | ||
| ) : ( | ||
| <ReportActionsView | ||
| report={report} | ||
| reportActions={reportActions} | ||
| isLoadingInitialReportActions={reportMetadata?.isLoadingInitialReportActions} | ||
| hasNewerActions={hasNewerActions} | ||
| hasOlderActions={hasOlderActions} | ||
| parentReportAction={parentReportAction} | ||
| transactionThreadReportID={transactionThreadReportID} | ||
| /> | ||
| <View style={[styles.flex1, styles.flexRow]}> | ||
| {shouldShowWideRHPReceipt && ( | ||
| <Animated.View style={styles.wideRHPMoneyRequestReceiptViewContainer}> | ||
| <ScrollView contentContainerStyle={styles.wideRHPMoneyRequestReceiptViewScrollViewContainer}> | ||
| <MoneyRequestReceiptView | ||
| allReports={allReports} | ||
|
Contributor
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. Unrelated, but I dont understand why this component should be getting full reports collection
Contributor
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. the components needs parent and chat report so we could have just passed the two, I believe @adamgrzybowski is in blame so ideally SWM can take a look at this |
||
| report={transactionThreadReport} | ||
| fillSpace | ||
| isDisplayedInWideRHP | ||
| /> | ||
| </ScrollView> | ||
| </Animated.View> | ||
| )} | ||
| {shouldDisplayReportFooter ? ( | ||
| <> | ||
| <ReportFooter | ||
| <View style={[[styles.flex1, styles.justifyContentEnd, styles.overflowHidden]]}> | ||
| {shouldDisplayMoneyRequestActionsList ? ( | ||
| <MoneyRequestReportActionsList | ||
| report={report} | ||
| reportMetadata={reportMetadata} | ||
| policy={policy} | ||
| pendingAction={reportPendingAction} | ||
| isComposerFullSize={!!isComposerFullSize} | ||
| lastReportAction={lastReportAction} | ||
| reportTransactions={transactions} | ||
| // If the report is from the 'Send Money' flow, we add the comment to the `iou` report because for these we don't combine reportActions even if there is a single transaction (they always have a single transaction) | ||
| transactionThreadReportID={isSentMoneyReport ? undefined : transactionThreadReportID} | ||
| transactions={visibleTransactions} | ||
| hasPendingDeletionTransaction={hasPendingDeletionTransaction} | ||
| newTransactions={newTransactions} | ||
| reportActions={reportActions} | ||
| violations={allReportViolations} | ||
| hasOlderActions={hasOlderActions} | ||
| hasNewerActions={hasNewerActions} | ||
| showReportActionsLoadingState={isLoadingInitialReportActions && !reportMetadata?.hasOnceLoadedReportActions} | ||
| /> | ||
| ) : ( | ||
| <ReportActionsView | ||
| report={report} | ||
| reportActions={reportActions} | ||
| isLoadingInitialReportActions={reportMetadata?.isLoadingInitialReportActions} | ||
| hasNewerActions={hasNewerActions} | ||
| hasOlderActions={hasOlderActions} | ||
| parentReportAction={parentReportAction} | ||
| transactionThreadReportID={transactionThreadReportID} | ||
| /> | ||
| <PortalHost name="suggestions" /> | ||
| </> | ||
| ) : null} | ||
| )} | ||
| {shouldDisplayReportFooter ? ( | ||
| <> | ||
| <ReportFooter | ||
| report={report} | ||
| reportMetadata={reportMetadata} | ||
| policy={policy} | ||
| pendingAction={reportPendingAction} | ||
| isComposerFullSize={!!isComposerFullSize} | ||
| lastReportAction={lastReportAction} | ||
| reportTransactions={transactions} | ||
| // If the report is from the 'Send Money' flow, we add the comment to the `iou` report because for these we don't combine reportActions even if there is a single transaction (they always have a single transaction) | ||
| transactionThreadReportID={isSentMoneyReport ? undefined : transactionThreadReportID} | ||
| /> | ||
| <PortalHost name="suggestions" /> | ||
| </> | ||
| ) : null} | ||
| </View> | ||
| </View> | ||
| </OfflineWithFeedback> | ||
| </View> | ||
|
|
||
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.
I feel like this should be abstracted out