Skip to content

Commit 8c86593

Browse files
authored
Merge pull request Expensify#66236 from Krishna2323/krishna2323/issue/65089
fix: App download banner overlaps the choose file button
2 parents 79723e8 + a47bbe1 commit 8c86593

2 files changed

Lines changed: 26 additions & 7 deletions

File tree

src/components/DownloadAppBanner.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
22
import {View} from 'react-native';
3+
import type {LayoutChangeEvent} from 'react-native';
34
import useHasLoggedIntoMobileApp from '@hooks/useHasLoggedIntoMobileApp';
45
import useLocalize from '@hooks/useLocalize';
56
import useThemeStyles from '@hooks/useThemeStyles';
@@ -9,7 +10,11 @@ import ROUTES from '@src/ROUTES';
910
import Button from './Button';
1011
import {ExpensifyMobileApp} from './Icon/Illustrations';
1112

12-
function DownloadAppBanner() {
13+
type DownloadAppBannerProps = {
14+
onLayout?: (e: LayoutChangeEvent) => void;
15+
};
16+
17+
function DownloadAppBanner({onLayout}: DownloadAppBannerProps) {
1318
const styles = useThemeStyles();
1419
const {translate} = useLocalize();
1520
const {hasLoggedIntoMobileApp, isLastMobileAppLoginLoaded} = useHasLoggedIntoMobileApp();
@@ -19,7 +24,10 @@ function DownloadAppBanner() {
1924
}
2025

2126
return (
22-
<View style={[styles.ph2, styles.mb2, styles.stickToBottom]}>
27+
<View
28+
style={[styles.ph2, styles.mb2, styles.stickToBottom, styles.pt2]}
29+
onLayout={onLayout}
30+
>
2331
<BillingBanner
2432
icon={ExpensifyMobileApp}
2533
title={translate('common.getTheApp')}

src/pages/iou/request/step/IOURequestStepScan/index.tsx

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -965,8 +965,19 @@ function IOURequestStepScan({
965965
</>
966966
);
967967

968+
const [containerHeight, setContainerHeight] = useState(0);
969+
const [desktopUploadViewHeight, setDesktopUploadViewHeight] = useState(0);
970+
const [downloadAppBannerHeight, setDownloadAppBannerHeight] = useState(0);
971+
/* We use isMobile() here to explicitly hide DownloadAppBanner component on both mobile web and native apps */
972+
const shouldHideDownloadAppBanner = isMobile() || downloadAppBannerHeight + desktopUploadViewHeight + styles.uploadFileView(isSmallScreenWidth).paddingVertical * 2 > containerHeight;
973+
968974
const desktopUploadView = () => (
969-
<>
975+
<View
976+
style={[styles.alignItemsCenter, styles.justifyContentCenter]}
977+
onLayout={(e) => {
978+
setDesktopUploadViewHeight(e.nativeEvent.layout.height);
979+
}}
980+
>
970981
{PDFValidationComponent}
971982
<ReceiptUpload
972983
width={CONST.RECEIPT.ICON_SIZE}
@@ -1005,7 +1016,7 @@ function IOURequestStepScan({
10051016
/>
10061017
)}
10071018
</AttachmentPicker>
1008-
</>
1019+
</View>
10091020
);
10101021

10111022
return (
@@ -1017,7 +1028,8 @@ function IOURequestStepScan({
10171028
>
10181029
{(isDraggingOverWrapper) => (
10191030
<View
1020-
onLayout={() => {
1031+
onLayout={(event) => {
1032+
setContainerHeight(event.nativeEvent.layout.height);
10211033
if (!onLayout) {
10221034
return;
10231035
}
@@ -1037,8 +1049,7 @@ function IOURequestStepScan({
10371049
dropInnerWrapperStyles={styles.receiptDropInnerWrapper(true)}
10381050
/>
10391051
</DragAndDropConsumer>
1040-
{/* We use isMobile() here to explicitly hide DownloadAppBanner component on both mobile web and native apps */}
1041-
{!isMobile() && <DownloadAppBanner />}
1052+
{!shouldHideDownloadAppBanner && <DownloadAppBanner onLayout={(e) => setDownloadAppBannerHeight(e.nativeEvent.layout.height)} />}
10421053
{ErrorModal}
10431054
{startLocationPermissionFlow && !!receiptFiles.length && (
10441055
<LocationPermissionModal

0 commit comments

Comments
 (0)