diff --git a/src/pages/ShareCodePage.tsx b/src/pages/ShareCodePage.tsx index ce2d8e005e4d..d7e86b3101f5 100644 --- a/src/pages/ShareCodePage.tsx +++ b/src/pages/ShareCodePage.tsx @@ -1,10 +1,14 @@ -import React from 'react'; +import React, {useMemo, useRef} from 'react'; import {View} from 'react-native'; +import type {ImageSourcePropType} from 'react-native'; import type {OnyxEntry} from 'react-native-onyx'; +import expensifyLogo from '@assets/images/expensify-logo-round-transparent.png'; import ContextMenuItem from '@components/ContextMenuItem'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import * as Expensicons from '@components/Icon/Expensicons'; import MenuItem from '@components/MenuItem'; +import QRShare from '@components/QRShare'; +import type {QRShareHandle} from '@components/QRShare/types'; import ScreenWrapper from '@components/ScreenWrapper'; import ScrollView from '@components/ScrollView'; import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; @@ -13,7 +17,9 @@ import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import Clipboard from '@libs/Clipboard'; import Navigation from '@libs/Navigation/Navigation'; +import * as ReportUtils from '@libs/ReportUtils'; import * as Url from '@libs/Url'; +import * as UserUtils from '@libs/UserUtils'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; import type {Report} from '@src/types/onyx'; @@ -29,10 +35,30 @@ function ShareCodePage({report}: ShareCodePageProps) { const themeStyles = useThemeStyles(); const {translate} = useLocalize(); const {environmentURL} = useEnvironment(); + const qrCodeRef = useRef(null); const currentUserPersonalDetails = useCurrentUserPersonalDetails(); const isReport = !!report?.reportID; + const subtitle = useMemo(() => { + if (isReport) { + if (ReportUtils.isExpenseReport(report)) { + return ReportUtils.getPolicyName(report); + } + if (ReportUtils.isMoneyRequestReport(report)) { + // generate subtitle from participants + return ReportUtils.getVisibleMemberIDs(report) + .map((accountID) => ReportUtils.getDisplayNameForParticipant(accountID)) + .join(' & '); + } + + return ReportUtils.getParentNavigationSubtitle(report).workspaceName ?? ReportUtils.getChatRoomSubtitle(report); + } + + return currentUserPersonalDetails.login; + }, [report, currentUserPersonalDetails, isReport]); + + const title = isReport ? ReportUtils.getReportName(report) : currentUserPersonalDetails.displayName ?? ''; const urlWithTrailingSlash = Url.addTrailingForwardSlash(environmentURL); const url = isReport ? `${urlWithTrailingSlash}${ROUTES.REPORT_WITH_ID.getRoute(report.reportID)}` @@ -46,13 +72,24 @@ function ShareCodePage({report}: ShareCodePageProps) { shouldShowBackButton /> - {/* + + {/* Right now QR code download button is not shown anymore This is a temporary measure because right now it's broken because of the Fabric update. We need to wait for react-native v0.74 to be released so react-native-view-shot gets fixed. Please see https://github.com/Expensify/App/issues/40110 to see if it can be re-enabled. */} + + (null); const {isSmallScreenWidth} = useWindowDimensions(); const session = useSession(); + const policyName = policy?.name ?? ''; const id = policy?.id ?? ''; const adminEmail = session?.email ?? ''; const urlWithTrailingSlash = Url.addTrailingForwardSlash(environmentURL); @@ -41,13 +48,23 @@ function WorkspaceProfileSharePage({policy}: WithPolicyProps) { /> - {/* - Right now QR code download button is not shown anymore - This is a temporary measure because right now it's broken because of the Fabric update. - We need to wait for react-native v0.74 to be released so react-native-view-shot gets fixed. - - Please see https://github.com/Expensify/App/issues/40110 to see if it can be re-enabled. - */} + + {/* + Right now QR code download button is not shown anymore + This is a temporary measure because right now it's broken because of the Fabric update. + We need to wait for react-native v0.74 to be released so react-native-view-shot gets fixed. + + Please see https://github.com/Expensify/App/issues/40110 to see if it can be re-enabled. + */} + +