Skip to content

Commit af2b4be

Browse files
committed
hide banner when screen height is not enough.
Signed-off-by: krishna2323 <belivethatkg@gmail.com>
1 parent c4b47ba commit af2b4be

2 files changed

Lines changed: 33 additions & 17 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.mtAuto]}>
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: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,10 @@ import DragAndDropConsumer from '@components/DragAndDrop/Consumer';
1818
import {DragAndDropContext} from '@components/DragAndDrop/Provider';
1919
import DropZoneUI from '@components/DropZone/DropZoneUI';
2020
import FeatureTrainingModal from '@components/FeatureTrainingModal';
21-
import FixedFooter from '@components/FixedFooter';
2221
import Icon from '@components/Icon';
2322
import * as Expensicons from '@components/Icon/Expensicons';
2423
import LocationPermissionModal from '@components/LocationPermissionModal';
2524
import PressableWithFeedback from '@components/Pressable/PressableWithFeedback';
26-
import ScrollView from '@components/ScrollView';
2725
import Text from '@components/Text';
2826
import TextLink from '@components/TextLink';
2927
import withCurrentUserPersonalDetails from '@components/withCurrentUserPersonalDetails';
@@ -973,13 +971,23 @@ function IOURequestStepScan({
973971
</>
974972
);
975973

974+
const [containerHeight, setContainerHeight] = useState(0);
975+
const [desktopUploadViewHeight, setDesktopUploadViewHeight] = useState(0);
976+
const [bannerHeight, setBannerHeight] = useState(0);
977+
const shouldHideBanner = bannerHeight + desktopUploadViewHeight + styles.uploadFileView(isSmallScreenWidth).paddingVertical * 2 > containerHeight;
978+
976979
const desktopUploadView = () => (
977-
<ScrollView contentContainerStyle={[styles.flexGrow1, styles.alignItemsCenter, styles.justifyContentCenter, styles.pt10]}>
980+
<View
981+
style={[!isMobile() && styles.alignItemsCenter, styles.justifyContentCenter]}
982+
onLayout={(e) => {
983+
if (isMobile()) {
984+
return;
985+
}
986+
setDesktopUploadViewHeight(e.nativeEvent.layout.height);
987+
}}
988+
>
978989
{PDFValidationComponent}
979-
<View
980-
onLayout={({nativeEvent}) => setReceiptImageTopPosition(PixelRatio.roundToNearestPixel((nativeEvent.layout as DOMRect).top))}
981-
// style={styles.mtAuto}
982-
>
990+
<View onLayout={({nativeEvent}) => setReceiptImageTopPosition(PixelRatio.roundToNearestPixel((nativeEvent.layout as DOMRect).top))}>
983991
<ReceiptUpload
984992
width={CONST.RECEIPT.ICON_SIZE}
985993
height={CONST.RECEIPT.ICON_SIZE}
@@ -1019,7 +1027,7 @@ function IOURequestStepScan({
10191027
/>
10201028
)}
10211029
</AttachmentPicker>
1022-
</ScrollView>
1030+
</View>
10231031
);
10241032

10251033
return (
@@ -1031,21 +1039,19 @@ function IOURequestStepScan({
10311039
>
10321040
{(isDraggingOverWrapper) => (
10331041
<View
1034-
onLayout={() => {
1042+
onLayout={(event) => {
1043+
if (!isMobile()) {
1044+
setContainerHeight(event.nativeEvent.layout.height);
1045+
}
10351046
if (!onLayout) {
10361047
return;
10371048
}
10381049
onLayout(setTestReceiptAndNavigate);
10391050
}}
1040-
style={[styles.flex1, !isMobile() && styles.uploadFileView(isSmallScreenWidth), !isMobile() && styles.p0]}
1051+
style={[styles.flex1, !isMobile() && styles.uploadFileView(isSmallScreenWidth)]}
10411052
>
10421053
<View style={[styles.flex1, !isMobile() && styles.alignItemsCenter, styles.justifyContentCenter]}>
10431054
{!(isDraggingOver ?? isDraggingOverWrapper) && (isMobile() ? mobileCameraView() : desktopUploadView())}
1044-
{!isMobile() && (
1045-
<FixedFooter style={styles.p0}>
1046-
<DownloadAppBanner />
1047-
</FixedFooter>
1048-
)}
10491055
</View>
10501056
{/* TODO: remove beta check after the feature is enabled */}
10511057
{canUseMultiDragAndDrop ? (
@@ -1072,6 +1078,8 @@ function IOURequestStepScan({
10721078
receiptImageTopPosition={receiptImageTopPosition}
10731079
/>
10741080
)}
1081+
{/* We use isMobile() here to explicitly hide DownloadAppBanner component on both mobile web and native apps */}
1082+
{!isMobile() && !shouldHideBanner && <DownloadAppBanner onLayout={(e) => setBannerHeight(e.nativeEvent.layout.height)} />}
10751083
{ErrorModal}
10761084
{startLocationPermissionFlow && !!receiptFiles.length && (
10771085
<LocationPermissionModal

0 commit comments

Comments
 (0)