Skip to content

Commit

Permalink
finish implementing qr share card
Browse files Browse the repository at this point in the history
  • Loading branch information
Christoph Pader committed May 10, 2023
1 parent fe000c0 commit fdd3473
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 24 deletions.
Binary file added assets/images/avatars/room.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions assets/images/expensify_wordmark_white.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 33 additions & 10 deletions src/components/QRShare.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Text from './Text';
import withWindowDimensions, {windowDimensionsPropTypes} from './withWindowDimensions';
import compose from '../libs/compose';
import variables from '../styles/variables';
import ExpensifyWordmark from '../../assets/images/expensify-wordmark.svg';

const propTypes = {
type: PropTypes.string.isRequired,
Expand All @@ -32,33 +33,55 @@ class QRShare extends React.Component {
constructor(props) {
super(props);

this.size = (this.props.isSmallScreenWidth ? variables.sideBarWidth : Dimensions.get('window').width) - 100;
const defaultQrCodeSize = this.props.isSmallScreenWidth ? (Dimensions.get('window').width) - 75 : variables.sideBarWidth;

this.state = {
qrCodeSize: defaultQrCodeSize,
};

this.url = this.props.type === 'profile' ? `https://new.expensify.com/details?login=${this.props.value}` : `https://new.expensify.com/r/${this.props.value}`;

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

onLayout = (event) => {
this.setState({
qrCodeSize: event.nativeEvent.layout.width - 64,
});
}

render() {
return (
<View style={styles.shareCodeContainer}>
<Text family="EXP_NEUE_BOLD" fontSize={30} style={{marginBottom: 20}} color={defaultTheme.borderFocus}>Expensify</Text>

<View style={styles.shareCodeContainer} onLayout={this.onLayout}>
<View style={{
alignSelf: 'stretch',
height: 27,
marginBottom: 20,
}}
>
<ExpensifyWordmark
fill={defaultTheme.borderFocus}
width="100%"
height="100%"
resizeMode="fill"
/>
</View>
<QRCodeLibrary
value={this.url}
logo={this.props.logo}
getRef={c => (this.svg = c)}
logoBackgroundColor="transparent"
logoSize={this.size * 0.3}
logoBorderRadius={this.size}
logoMargin={200}
size={this.size}
logoSize={this.state.qrCodeSize * 0.3}
logoBorderRadius={this.state.qrCodeSize}
size={this.state.qrCodeSize}
backgroundColor={defaultTheme.highlightBG}
color={defaultTheme.text}
/>

<Text family="EXP_NEW_KANSAS_MEDIUM" fontSize={25} style={{marginTop: 20}}>{this.props.title}</Text>
<Text family="EXP_NEW_KANSAS_MEDIUM" fontSize={22} style={{marginTop: 15}}>{this.props.title}</Text>

{this.props.subtitle && (
<Text family="EXP_NEUE_BOLD" fontSize={15} style={{marginBottom: 20}}>{this.props.subtitle}</Text>
<Text family="EXP_NEUE_BOLD" fontSize={13} style={{marginTop: 4}}>{this.props.subtitle}</Text>
)}
</View>
);
Expand Down
15 changes: 5 additions & 10 deletions src/pages/ShareCodePage.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react';
import {View} from 'react-native';
import PropTypes from 'prop-types';
import {withOnyx} from 'react-native-onyx';
import ScreenWrapper from '../components/ScreenWrapper';
import HeaderWithCloseButton from '../components/HeaderWithCloseButton';
import Navigation from '../libs/Navigation/Navigation';
Expand All @@ -11,8 +10,8 @@ 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.svg';
import ONYXKEYS from '../ONYXKEYS';
import roomAvatar from '../../assets/images/avatars/room.png';
import * as ReportUtils from '../libs/ReportUtils';

const propTypes = {
/** Navigation route context info provided by react navigation */
Expand Down Expand Up @@ -42,6 +41,8 @@ class ShareCodePage extends React.Component {
const reportId = this.props.route?.params?.reportID;
const isReport = this.props.report != null && this.props.report.reportID != null;

console.log(this.props.report);

return (
<ScreenWrapper>
<HeaderWithCloseButton
Expand All @@ -56,7 +57,7 @@ class ShareCodePage extends React.Component {
type={isReport ? 'report' : 'profile'}
value={isReport ? reportId : this.props.session.email}
title={isReport ? this.props.report.reportName : this.props.currentUserPersonalDetails.displayName}
subtitle={isReport ? undefined : this.props.session.email}
subtitle={isReport ? ReportUtils.getPolicyName(this.props.report) : this.props.session.email}
logo={isReport ? roomAvatar : this.props.currentUserPersonalDetails.avatar}
download={() => null}
/>
Expand All @@ -71,11 +72,5 @@ ShareCodePage.defaultProps = defaultProps;

export default compose(
withLocalize,
withOnyx({
report: {
// eslint-disable-next-line es/no-optional-chaining
key: ({route}) => (route.params?.reportId != null ? `${ONYXKEYS.COLLECTION.REPORT}${route.params.reportID}` : undefined),
},
}),
withCurrentUserPersonalDetails,
)(ShareCodePage);
9 changes: 5 additions & 4 deletions src/styles/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -3194,17 +3194,18 @@ const styles = {
},

shareCodePage: {
alignItems: 'center',
paddingHorizontal: 38.5,
},

shareCodeContainer: {
width: '100%',
alignItems: 'center',
paddingHorizontal: 30,
paddingHorizontal: 32,
paddingVertical: 20,
marginHorizontal: 30,
borderRadius: 20,
overflow: 'hidden',
borderColor: themeColors.borderFocus,
borderWidth: 3,
borderWidth: 2,
backgroundColor: themeColors.highlightBG,
},
};
Expand Down

0 comments on commit fdd3473

Please sign in to comment.