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

fix QR code expand to full size #45373

Merged
merged 3 commits into from
Jul 19, 2024
Merged
Changes from 1 commit
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
13 changes: 11 additions & 2 deletions src/components/QRShare/index.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
import type {ForwardedRef} from 'react';
import React, {forwardRef, useImperativeHandle, useRef, useState} from 'react';
import type {LayoutChangeEvent} from 'react-native';
import {View} from 'react-native';
import {Platform, View} from 'react-native';
import type {Svg} from 'react-native-svg';
import ExpensifyWordmark from '@assets/images/expensify-wordmark.svg';
import ImageSVG from '@components/ImageSVG';
import QRCode from '@components/QRCode';
import Text from '@components/Text';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import useWindowDimensions from '@hooks/useWindowDimensions';
import * as Browser from '@libs/Browser';
import variables from '@styles/variables';
import type {QRShareHandle, QRShareProps} from './types';

function QRShare({url, title, subtitle, logo, logoRatio, logoMarginRatio}: QRShareProps, ref: ForwardedRef<QRShareHandle>) {
const styles = useThemeStyles();
const theme = useTheme();
const {isSmallScreenWidth} = useResponsiveLayout();
const isMobilePlatform = Platform.OS === 'android' || Platform.OS === 'ios';
Copy link
Contributor

@alitoshmatov alitoshmatov Jul 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we 100% sure that we need Platform check here, isn't isSmallScreenWidth sufficient

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your feedback. I checked and using isSmallScreenWidth is enough to detect the container width. I have updated the condition to get the container width. Please help me check it again!

const isMobileBrowser = Browser.isMobile();
const isMobile = isMobilePlatform || isMobileBrowser;
const {windowWidth} = useWindowDimensions();
const qrCodeContainerWidth = isMobile || isSmallScreenWidth ? windowWidth : variables.sideBarWidth;

const [qrCodeSize, setQrCodeSize] = useState<number | undefined>();
const [qrCodeSize, setQrCodeSize] = useState<number>(qrCodeContainerWidth - styles.ph5.paddingHorizontal * 2 - variables.qrShareHorizontalPadding * 2);
const svgRef = useRef<Svg>();

useImperativeHandle(
Expand Down
Loading