Skip to content

Commit

Permalink
Merge pull request #19984 from alitoshmatov/qr-code-update
Browse files Browse the repository at this point in the history
Qr code update
  • Loading branch information
robertjchen authored Jun 5, 2023
2 parents 5269e2a + 538406c commit 5c7b3c2
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 5 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions src/CONST.js
Original file line number Diff line number Diff line change
Expand Up @@ -2443,6 +2443,12 @@ const CONST = {
FLAG_SEVERITY_HARASSMENT: 'harassment',
FLAG_SEVERITY_ASSAULT: 'assault',
},
QR: {
DEFAULT_LOGO_SIZE_RATIO: 0.25,
DEFAULT_LOGO_MARGIN_RATIO: 0.02,
EXPENSIFY_LOGO_SIZE_RATIO: 0.22,
EXPENSIFY_LOGO_MARGIN_RATIO: 0.03,
},
};

export default CONST;
16 changes: 14 additions & 2 deletions src/components/QRCode/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import QRCodeLibrary from 'react-native-qrcode-svg';
import PropTypes from 'prop-types';
import defaultTheme from '../../styles/themes/default';
import CONST from '../../CONST';

const propTypes = {
/**
Expand All @@ -13,6 +14,14 @@ const propTypes = {
* Follows ImageProps href from react-native-svg that is used by react-native-qrcode-svg.
*/
logo: PropTypes.oneOfType([PropTypes.shape({uri: PropTypes.string}), PropTypes.number, PropTypes.string]),
/**
* The size ratio of logo to QR code
*/
logoRatio: PropTypes.number,
/**
* The size ratio of margin around logo to QR code
*/
logoMarginRatio: PropTypes.number,
/**
* The QRCode size
*/
Expand All @@ -38,6 +47,8 @@ const defaultProps = {
color: defaultTheme.text,
backgroundColor: defaultTheme.highlightBG,
getRef: undefined,
logoRatio: CONST.QR.DEFAULT_LOGO_SIZE_RATIO,
logoMarginRatio: CONST.QR.DEFAULT_LOGO_MARGIN_RATIO,
};

function QRCode(props) {
Expand All @@ -47,8 +58,9 @@ function QRCode(props) {
value={props.url}
size={props.size}
logo={props.logo}
logoBackgroundColor="transparent"
logoSize={props.size * 0.3}
logoBackgroundColor={props.backgroundColor}
logoSize={props.size * props.logoRatio}
logoMargin={props.size * props.logoMarginRatio}
logoBorderRadius={props.size}
backgroundColor={props.backgroundColor}
color={props.color}
Expand Down
2 changes: 2 additions & 0 deletions src/components/QRShare/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ class QRShare extends Component {
url={this.props.url}
logo={this.props.logo}
size={this.state.qrCodeSize}
logoRatio={this.props.logoRatio}
logoMarginRatio={this.props.logoMarginRatio}
/>

<Text
Expand Down
8 changes: 8 additions & 0 deletions src/components/QRShare/propTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ const qrSharePropTypes = {
* The logo which will be display in the middle of the QR code
*/
logo: PropTypes.oneOfType([PropTypes.shape({uri: PropTypes.string}), PropTypes.number, PropTypes.string]),
/**
* The size ratio of logo to QR code
*/
logoRatio: PropTypes.number,
/**
* The size ratio of margin around logo to QR code
*/
logoMarginRatio: PropTypes.number,
};

const defaultProps = {
Expand Down
6 changes: 4 additions & 2 deletions src/pages/ShareCodePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import compose from '../libs/compose';
import reportPropTypes from './reportPropTypes';
import withCurrentUserPersonalDetails, {withCurrentUserPersonalDetailsDefaultProps, withCurrentUserPersonalDetailsPropTypes} from '../components/withCurrentUserPersonalDetails';
import styles from '../styles/styles';
import roomAvatar from '../../assets/images/avatars/room.png';
import expensifyLogo from '../../assets/images/expensify-logo-round-transparent.png';
import * as ReportUtils from '../libs/ReportUtils';
import MenuItem from '../components/MenuItem';
import Clipboard from '../libs/Clipboard';
Expand Down Expand Up @@ -61,7 +61,9 @@ class ShareCodePage extends React.Component {
url={url}
title={isReport ? this.props.report.reportName : this.props.currentUserPersonalDetails.displayName}
subtitle={isReport ? subtitle : this.props.session.email}
logo={isReport ? roomAvatar : UserUtils.getAvatarUrl(this.props.currentUserPersonalDetails.avatar, this.props.currentUserPersonalDetails.login)}
logo={isReport ? expensifyLogo : UserUtils.getAvatarUrl(this.props.currentUserPersonalDetails.avatar, this.props.currentUserPersonalDetails.login)}
logoRatio={isReport ? CONST.QR.EXPENSIFY_LOGO_SIZE_RATIO : CONST.QR.DEFAULT_LOGO_SIZE_RATIO}
logoMarginRatio={isReport ? CONST.QR.EXPENSIFY_LOGO_MARGIN_RATIO : CONST.QR.DEFAULT_LOGO_MARGIN_RATIO}
/>
</View>

Expand Down
5 changes: 4 additions & 1 deletion src/pages/settings/Security/TwoFactorAuth/VerifyPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import Clipboard from '../../../../libs/Clipboard';
import FixedFooter from '../../../../components/FixedFooter';
import TwoFactorAuthForm from './TwoFactorAuthForm';
import QRCode from '../../../../components/QRCode';
import expensifyLogo from '../../../../../assets/images/expensify-logo-round-dark.png';
import expensifyLogo from '../../../../../assets/images/expensify-logo-round-transparent.png';
import CONST from '../../../../CONST';

const propTypes = {
...withLocalizePropTypes,
Expand Down Expand Up @@ -115,6 +116,8 @@ function VerifyPage(props) {
<QRCode
url={buildAuthenticatorUrl()}
logo={expensifyLogo}
logoRatio={CONST.QR.EXPENSIFY_LOGO_SIZE_RATIO}
logoMarginRatio={CONST.QR.EXPENSIFY_LOGO_MARGIN_RATIO}
/>
</View>
<Text style={styles.mt5}>{props.translate('twoFactorAuth.addKey')}</Text>
Expand Down

0 comments on commit 5c7b3c2

Please sign in to comment.