forked from Expensify/App
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Expensify#36907 from narefyev91/add-share-page-for…
…-workspace-profile Add Share page for Workspace Profile
- Loading branch information
Showing
11 changed files
with
125 additions
and
1 deletion.
There are no files selected for viewing
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
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
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
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,5 @@ | ||
import type ShouldAllowDownloadQRCode from './types'; | ||
|
||
const shouldAllowDownloadQRCode: ShouldAllowDownloadQRCode = true; | ||
|
||
export default shouldAllowDownloadQRCode; |
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,5 @@ | ||
import type ShouldAllowDownloadQRCode from './types'; | ||
|
||
const shouldAllowDownloadQRCode: ShouldAllowDownloadQRCode = false; | ||
|
||
export default shouldAllowDownloadQRCode; |
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,3 @@ | ||
type ShouldAllowDownloadQRCode = boolean; | ||
|
||
export default ShouldAllowDownloadQRCode; |
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,88 @@ | ||
import React, {useRef} from 'react'; | ||
import {ScrollView, View} from 'react-native'; | ||
import type {ImageSourcePropType} from 'react-native'; | ||
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 QRShareWithDownload from '@components/QRShare/QRShareWithDownload'; | ||
import type QRShareWithDownloadHandle from '@components/QRShare/QRShareWithDownload/types'; | ||
import ScreenWrapper from '@components/ScreenWrapper'; | ||
import useEnvironment from '@hooks/useEnvironment'; | ||
import useLocalize from '@hooks/useLocalize'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import useWindowDimensions from '@hooks/useWindowDimensions'; | ||
import Clipboard from '@libs/Clipboard'; | ||
import Navigation from '@libs/Navigation/Navigation'; | ||
import shouldAllowDownloadQRCode from '@libs/shouldAllowDownloadQRCode'; | ||
import * as Url from '@libs/Url'; | ||
import CONST from '@src/CONST'; | ||
import ROUTES from '@src/ROUTES'; | ||
import withPolicy from './withPolicy'; | ||
import type {WithPolicyProps} from './withPolicy'; | ||
|
||
function WorkspaceProfileSharePage({policy}: WithPolicyProps) { | ||
const themeStyles = useThemeStyles(); | ||
const {translate} = useLocalize(); | ||
const {environmentURL} = useEnvironment(); | ||
const qrCodeRef = useRef<QRShareWithDownloadHandle>(null); | ||
const {isSmallScreenWidth} = useWindowDimensions(); | ||
|
||
const policyName = policy?.name ?? ''; | ||
const id = policy?.id ?? ''; | ||
const urlWithTrailingSlash = Url.addTrailingForwardSlash(environmentURL); | ||
|
||
const url = `${urlWithTrailingSlash}${ROUTES.WORKSPACE_PROFILE.getRoute(id)}`; | ||
return ( | ||
<ScreenWrapper | ||
testID={WorkspaceProfileSharePage.displayName} | ||
shouldShowOfflineIndicatorInWideScreen | ||
> | ||
<HeaderWithBackButton | ||
title={translate('common.share')} | ||
onBackButtonPress={Navigation.goBack} | ||
/> | ||
<ScrollView style={[themeStyles.flex1, themeStyles.pt2]}> | ||
<View style={[themeStyles.flex1, isSmallScreenWidth ? themeStyles.workspaceSectionMobile : themeStyles.workspaceSection]}> | ||
<View style={[themeStyles.workspaceSectionMobile, themeStyles.ph9]}> | ||
<QRShareWithDownload | ||
ref={qrCodeRef} | ||
url={url} | ||
title={policyName} | ||
logo={(policy?.avatar ? policy.avatar : expensifyLogo) as ImageSourcePropType} | ||
logoRatio={CONST.QR.DEFAULT_LOGO_SIZE_RATIO} | ||
logoMarginRatio={CONST.QR.DEFAULT_LOGO_MARGIN_RATIO} | ||
/> | ||
</View> | ||
|
||
<View style={[themeStyles.mt3, themeStyles.ph4]}> | ||
<ContextMenuItem | ||
isAnonymousAction | ||
text={translate('qrCodes.copy')} | ||
icon={Expensicons.Copy} | ||
successIcon={Expensicons.Checkmark} | ||
successText={translate('qrCodes.copied')} | ||
onPress={() => Clipboard.setString(url)} | ||
shouldLimitWidth={false} | ||
wrapperStyle={themeStyles.sectionMenuItemTopDescription} | ||
/> | ||
{shouldAllowDownloadQRCode && ( | ||
<MenuItem | ||
isAnonymousAction | ||
title={translate('common.download')} | ||
icon={Expensicons.Download} | ||
onPress={() => qrCodeRef.current?.download?.()} | ||
wrapperStyle={themeStyles.sectionMenuItemTopDescription} | ||
/> | ||
)} | ||
</View> | ||
</View> | ||
</ScrollView> | ||
</ScreenWrapper> | ||
); | ||
} | ||
|
||
WorkspaceProfileSharePage.displayName = 'WorkspaceProfileSharePage'; | ||
|
||
export default withPolicy(WorkspaceProfileSharePage); |