Skip to content

Commit 0a8ae6b

Browse files
authored
Merge pull request Expensify#62355 from nkdengineer/fix/62070
feat: Add QR code to app download links screen
2 parents 5a11c6b + d312086 commit 0a8ae6b

8 files changed

Lines changed: 79 additions & 25 deletions

File tree

src/CONST.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const CLOUDFRONT_DOMAIN = 'cloudfront.net';
2424
const CLOUDFRONT_URL = `https://d2k5nsl2zxldvw.${CLOUDFRONT_DOMAIN}`;
2525
const ACTIVE_EXPENSIFY_URL = addTrailingForwardSlash(Config?.NEW_EXPENSIFY_URL ?? 'https://new.expensify.com');
2626
const USE_EXPENSIFY_URL = 'https://use.expensify.com';
27+
const EXPENSIFY_MOBILE_URL = 'https://expensify.com/mobile';
2728
const EXPENSIFY_URL = 'https://www.expensify.com';
2829
const PLATFORM_OS_MACOS = 'Mac OS';
2930
const PLATFORM_IOS = 'iOS';
@@ -1061,6 +1062,7 @@ const CONST = {
10611062
DEFAULT_NUMBER_ID,
10621063
USE_EXPENSIFY_URL,
10631064
EXPENSIFY_URL,
1065+
EXPENSIFY_MOBILE_URL,
10641066
GOOGLE_MEET_URL_ANDROID: 'https://meet.google.com',
10651067
GOOGLE_DOC_IMAGE_LINK_MATCH: 'googleusercontent.com',
10661068
IMAGE_BASE64_MATCH: 'base64',
@@ -3217,6 +3219,10 @@ const CONST = {
32173219
LARGE: 'large',
32183220
},
32193221

3222+
QR_CODE_SIZE: {
3223+
APP_DOWNLOAD_LINKS: 172,
3224+
},
3225+
32203226
AVATAR_SIZE: {
32213227
X_LARGE: 'xlarge',
32223228
LARGE: 'large',

src/components/QRCode.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,11 @@ function QRCode({
8080
logo={logo}
8181
logoSVG={svgLogo}
8282
logoColor={svgLogoFillColor}
83-
logoBackgroundColor={logoBackgroundColor ?? theme.highlightBG}
83+
logoBackgroundColor={logoBackgroundColor ?? theme.appBG}
8484
logoSize={size * logoRatio}
8585
logoMargin={size * logoMarginRatio}
8686
logoBorderRadius={size}
87-
backgroundColor={backgroundColor ?? theme.highlightBG}
87+
backgroundColor={backgroundColor ?? theme.appBG}
8888
color={color ?? theme.text}
8989
/>
9090
);

src/components/QRShare/QRShareWithDownload/index.native.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ function QRShareWithDownload(props: QRShareProps, ref: ForwardedRef<QRShareWithD
1818
useImperativeHandle(
1919
ref,
2020
() => ({
21-
download: () => qrCodeScreenshotRef.current?.capture?.().then((uri) => fileDownload(uri, getQrCodeFileName(props.title), translate('fileDownload.success.qrMessage'))),
21+
download: () =>
22+
qrCodeScreenshotRef.current?.capture?.().then((uri) => fileDownload(uri, getQrCodeFileName(props.title ?? 'QRCode'), translate('fileDownload.success.qrMessage'))),
2223
}),
2324
[props.title, translate],
2425
);

src/components/QRShare/QRShareWithDownload/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function QRShareWithDownload(props: QRShareProps, ref: ForwardedRef<QRShareWithD
2323
return;
2424
}
2525

26-
svg.toDataURL((dataURL) => resolve(fileDownload(dataURL, getQrCodeFileName(props.title))));
26+
svg.toDataURL((dataURL) => resolve(fileDownload(dataURL, getQrCodeFileName(props.title ?? 'QRCode'))));
2727
}),
2828
}),
2929
[props.title],

src/components/QRShare/index.tsx

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ import useWindowDimensions from '@hooks/useWindowDimensions';
1414
import variables from '@styles/variables';
1515
import type {QRShareHandle, QRShareProps} from './types';
1616

17-
function QRShare({url, title, subtitle, logo, svgLogo, svgLogoFillColor, logoBackgroundColor, logoRatio, logoMarginRatio}: QRShareProps, ref: ForwardedRef<QRShareHandle>) {
17+
function QRShare(
18+
{url, title, subtitle, logo, svgLogo, svgLogoFillColor, logoBackgroundColor, logoRatio, logoMarginRatio, shouldShowExpensifyLogo = true, additionalStyles, size}: QRShareProps,
19+
ref: ForwardedRef<QRShareHandle>,
20+
) {
1821
const styles = useThemeStyles();
1922
const theme = useTheme();
2023
const {shouldUseNarrowLayout} = useResponsiveLayout();
@@ -39,16 +42,18 @@ function QRShare({url, title, subtitle, logo, svgLogo, svgLogoFillColor, logoBac
3942

4043
return (
4144
<View
42-
style={styles.shareCodeContainer}
45+
style={[styles.shareCodeContainer, additionalStyles]}
4346
onLayout={onLayout}
4447
>
45-
<View style={styles.expensifyQrLogo}>
46-
<ImageSVG
47-
contentFit="contain"
48-
src={ExpensifyWordmark}
49-
fill={theme.QRLogo}
50-
/>
51-
</View>
48+
{shouldShowExpensifyLogo && (
49+
<View style={styles.expensifyQrLogo}>
50+
<ImageSVG
51+
contentFit="contain"
52+
src={ExpensifyWordmark}
53+
fill={theme.QRLogo}
54+
/>
55+
</View>
56+
)}
5257

5358
<QRCode
5459
getRef={(svg) => (svgRef.current = svg)}
@@ -57,19 +62,21 @@ function QRShare({url, title, subtitle, logo, svgLogo, svgLogoFillColor, logoBac
5762
svgLogoFillColor={svgLogoFillColor}
5863
logoBackgroundColor={logoBackgroundColor}
5964
logo={logo}
60-
size={qrCodeSize}
65+
size={size ?? qrCodeSize}
6166
logoRatio={logoRatio}
6267
logoMarginRatio={logoMarginRatio}
6368
/>
6469

65-
<Text
66-
family="EXP_NEW_KANSAS_MEDIUM"
67-
fontSize={variables.fontSizeXLarge}
68-
numberOfLines={2}
69-
style={styles.qrShareTitle}
70-
>
71-
{title}
72-
</Text>
70+
{!!title && (
71+
<Text
72+
family="EXP_NEW_KANSAS_MEDIUM"
73+
fontSize={variables.fontSizeXLarge}
74+
numberOfLines={2}
75+
style={styles.qrShareTitle}
76+
>
77+
{title}
78+
</Text>
79+
)}
7380

7481
{!!subtitle && (
7582
<Text

src/components/QRShare/types.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import type React from 'react';
2-
import type {ImageSourcePropType} from 'react-native';
2+
import type {ImageSourcePropType, StyleProp, ViewStyle} from 'react-native';
33
import type {Svg, SvgProps} from 'react-native-svg';
4+
import type {ValueOf} from 'type-fest';
45
import type {QRCodeLogoMarginRatio, QRCodeLogoRatio} from '@components/QRCode';
6+
import type CONST from '@src/CONST';
57

68
type QRShareProps = {
79
/**
@@ -12,7 +14,7 @@ type QRShareProps = {
1214
/**
1315
* The title that is displayed below the QR Code (usually the user or report name)
1416
*/
15-
title: string;
17+
title?: string;
1618

1719
/**
1820
* The subtitle which will be shown below the title (usually user email or workspace name)
@@ -49,6 +51,21 @@ type QRShareProps = {
4951
* The size ratio of margin around logo to QR code
5052
*/
5153
logoMarginRatio?: QRCodeLogoMarginRatio;
54+
55+
/**
56+
* If true, the Expensify logo will be displayed
57+
*/
58+
shouldShowExpensifyLogo?: boolean;
59+
60+
/**
61+
* Additional styles to be applied to the QR code
62+
*/
63+
additionalStyles?: StyleProp<ViewStyle>;
64+
65+
/**
66+
* The size of the QR code
67+
*/
68+
size?: ValueOf<typeof CONST.QR_CODE_SIZE>;
5269
};
5370

5471
type QRShareHandle = {

src/pages/settings/AppDownloadLinks.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import React, {useRef} from 'react';
22
import type {View} from 'react-native';
3+
import expensifyLogo from '@assets/images/expensify-logo-round-transparent.png';
34
import HeaderWithBackButton from '@components/HeaderWithBackButton';
45
import * as Expensicons from '@components/Icon/Expensicons';
56
import MenuItem from '@components/MenuItem';
67
import type {MenuItemProps} from '@components/MenuItem';
8+
import QRShare from '@components/QRShare';
79
import ScreenWrapper from '@components/ScreenWrapper';
810
import ScrollView from '@components/ScrollView';
911
import useLocalize from '@hooks/useLocalize';
@@ -61,6 +63,17 @@ function AppDownloadLinksPage() {
6163
title={translate('initialSettingsPage.aboutPage.appDownloadLinks')}
6264
onBackButtonPress={() => Navigation.goBack()}
6365
/>
66+
67+
<QRShare
68+
url={CONST.EXPENSIFY_MOBILE_URL}
69+
logo={expensifyLogo}
70+
logoRatio={CONST.QR.EXPENSIFY_LOGO_SIZE_RATIO}
71+
logoMarginRatio={CONST.QR.EXPENSIFY_LOGO_MARGIN_RATIO}
72+
shouldShowExpensifyLogo={false}
73+
additionalStyles={[styles.qrCodeAppDownloadLinksStyles, styles.shareCodeContainerDownloadPadding]}
74+
size={CONST.QR_CODE_SIZE.APP_DOWNLOAD_LINKS}
75+
/>
76+
6477
<ScrollView style={[styles.mt3]}>
6578
{menuItems.map((item: DownloadMenuItem) => (
6679
<MenuItem

src/styles/index.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4482,7 +4482,17 @@ const styles = (theme: ThemeColors) =>
44824482
overflow: 'hidden',
44834483
borderColor: theme.borderFocus,
44844484
borderWidth: 2,
4485-
backgroundColor: theme.highlightBG,
4485+
},
4486+
4487+
shareCodeContainerDownloadPadding: {
4488+
paddingHorizontal: 12,
4489+
paddingVertical: 12,
4490+
},
4491+
4492+
qrCodeAppDownloadLinksStyles: {
4493+
width: 200,
4494+
height: 200,
4495+
margin: 'auto',
44864496
},
44874497

44884498
splashScreenHider: {

0 commit comments

Comments
 (0)