Skip to content
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

Bug fixes: QR codes #18946

Merged
merged 10 commits into from
May 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions assets/images/qrcode.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 9 additions & 4 deletions src/components/QRShare/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, {Component} from 'react';
import QRCodeLibrary from 'react-native-qrcode-svg';
import QrCode from 'react-native-qrcode-svg';
import {View} from 'react-native';
import withLocalize, {withLocalizePropTypes} from '../withLocalize';
import defaultTheme from '../../styles/themes/default';
Expand All @@ -22,16 +22,18 @@ class QRShare extends Component {
super(props);

this.state = {
qrCodeSize: 0,
qrCodeSize: 1,
};

this.onLayout = this.onLayout.bind(this);
this.getSvg = this.getSvg.bind(this);
}

onLayout(event) {
const containerWidth = event.nativeEvent.layout.width - variables.qrShareHorizontalPadding * 2 || 0;

this.setState({
qrCodeSize: event.nativeEvent.layout.width - variables.qrShareHorizontalPadding * 2,
qrCodeSize: Math.max(1, containerWidth),
});
}

Expand Down Expand Up @@ -59,7 +61,7 @@ class QRShare extends Component {
/>
</View>

<QRCodeLibrary
<QrCode
value={this.props.url}
logo={this.props.logo}
getRef={(svg) => (this.svg = svg)}
Expand All @@ -74,6 +76,7 @@ class QRShare extends Component {
<Text
family="EXP_NEW_KANSAS_MEDIUM"
fontSize={22}
numberOfLines={2}
style={{marginTop: 15}}
>
{this.props.title}
Expand All @@ -83,7 +86,9 @@ class QRShare extends Component {
<Text
family="EXP_NEUE_BOLD"
fontSize={13}
numberOfLines={1}
style={{marginTop: 4}}
color={defaultTheme.textSupporting}
>
{this.props.subtitle}
</Text>
Expand Down
4 changes: 4 additions & 0 deletions src/languages/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -1327,4 +1327,8 @@ export default {
replies: 'Replies',
reply: 'Reply',
},
qrCodes: {
copyUrlToClipboard: 'Copy URL to clipboard',
copied: 'Copied!',
},
};
4 changes: 4 additions & 0 deletions src/languages/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -1792,4 +1792,8 @@ export default {
replies: 'Respuestas',
reply: 'Respuesta',
},
qrCodes: {
copyUrlToClipboard: 'Copiar URL al portapapeles',
copied: '¡Copiado!',
},
};
10 changes: 6 additions & 4 deletions src/pages/ShareCodePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import Clipboard from '../libs/Clipboard';
import * as Expensicons from '../components/Icon/Expensicons';
import getPlatform from '../libs/getPlatform';
import CONST from '../CONST';
import ContextMenuItem from '../components/ContextMenuItem';

const propTypes = {
/** The report currently being looked at */
Expand Down Expand Up @@ -63,17 +64,18 @@ class ShareCodePage extends React.Component {
</View>

<View style={{marginTop: 36}}>
<MenuItem
title={this.props.translate('common.share')}
<ContextMenuItem
text={this.props.translate('qrCodes.copyUrlToClipboard')}
shouldShowRightIcon
icon={Expensicons.Link}
icon={Expensicons.Copy}
successIcon={Expensicons.Checkmark}
successText={this.props.translate('qrCodes.copied')}
onPress={() => Clipboard.setString(url)}
/>

{isNative && (
<MenuItem
title={this.props.translate('common.download')}
shouldShowRightIcon
icon={Expensicons.Download}
// eslint-disable-next-line es/no-optional-chaining
onPress={() => this.qrCodeRef.current?.download()}
Expand Down