Skip to content

Commit b9f7799

Browse files
authored
Merge pull request Expensify#87620 from software-mansion-labs/mrejdak/fix-empty-state
2 parents efb3d18 + 7938b89 commit b9f7799

2 files changed

Lines changed: 21 additions & 8 deletions

File tree

src/components/Search/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ function Search({
283283
const {isOffline} = useNetwork();
284284
const prevIsOffline = usePrevious(isOffline);
285285
// eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth
286-
const {shouldUseNarrowLayout, isSmallScreenWidth, isLargeScreenWidth} = useResponsiveLayout();
286+
const {shouldUseNarrowLayout, isSmallScreenWidth, isLargeScreenWidth, isInLandscapeMode} = useResponsiveLayout();
287287
const styles = useThemeStyles();
288288
const navigation = useNavigation<PlatformStackNavigationProp<SearchFullscreenNavigatorParamList>>();
289289
const isFocused = useIsFocused();
@@ -1550,12 +1550,14 @@ function Search({
15501550
) {
15511551
cancelNavigationSpans();
15521552
return (
1553-
<View style={[shouldUseNarrowLayout ? styles.searchListContentContainerStyles : styles.mt3, styles.flex1]}>
1553+
<View style={[styles.flex1, isInLandscapeMode ? undefined : [shouldUseNarrowLayout ? styles.searchListContentContainerStyles : styles.mt3]]}>
15541554
<EmptySearchView
15551555
similarSearchHash={similarSearchHash}
15561556
type={type}
15571557
hasResults={searchResults?.search?.hasResults}
15581558
queryJSON={queryJSON}
1559+
onScroll={onSearchListScroll}
1560+
contentContainerStyle={isInLandscapeMode ? styles.searchListContentContainerStyles : undefined}
15591561
/>
15601562
</View>
15611563
);

src/pages/Search/EmptySearchView.tsx

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ import {accountIDSelector} from '@selectors/Session';
33
import {validTransactionDraftIDsSelector} from '@selectors/TransactionDraft';
44
import React from 'react';
55
// eslint-disable-next-line no-restricted-imports
6-
import type {ImageStyle, TextStyle, ViewStyle} from 'react-native';
6+
import type {ImageStyle, NativeScrollEvent, NativeSyntheticEvent, StyleProp, TextStyle, ViewStyle} from 'react-native';
77
import {Linking, View} from 'react-native';
88
import type {OnyxCollection, OnyxEntry} from 'react-native-onyx';
9+
import Animated from 'react-native-reanimated';
910
import BookTravelButton from '@components/BookTravelButton';
1011
import GenericEmptyStateComponent from '@components/EmptyStateComponent/GenericEmptyStateComponent';
1112
import type {EmptyStateButton, HeaderMedia} from '@components/EmptyStateComponent/types';
1213
import {ModalActions} from '@components/Modal/Global/ModalContext';
13-
import ScrollView from '@components/ScrollView';
1414
import {SearchScopeProvider} from '@components/Search/SearchScopeProvider';
1515
import type {SearchQueryJSON} from '@components/Search/types';
1616
import Text from '@components/Text';
@@ -19,6 +19,7 @@ import useConfirmModal from '@hooks/useConfirmModal';
1919
import useCreateEmptyReportConfirmation from '@hooks/useCreateEmptyReportConfirmation';
2020
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
2121
import useHasEmptyReportsForPolicy from '@hooks/useHasEmptyReportsForPolicy';
22+
import useIsInLandscapeMode from '@hooks/useIsInLandscapeMode';
2223
import {useMemoizedLazyIllustrations} from '@hooks/useLazyAsset';
2324
import useLocalize from '@hooks/useLocalize';
2425
import useOnyx from '@hooks/useOnyx';
@@ -48,6 +49,8 @@ type EmptySearchViewProps = {
4849
type: SearchDataTypes;
4950
hasResults: boolean;
5051
queryJSON?: SearchQueryJSON;
52+
onScroll?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
53+
contentContainerStyle?: StyleProp<ViewStyle>;
5154
};
5255

5356
type EmptySearchViewContentProps = EmptySearchViewProps & {
@@ -70,7 +73,7 @@ type EmptySearchViewItem = {
7073
children?: React.ReactNode;
7174
};
7275

73-
function EmptySearchView({similarSearchHash, type, hasResults, queryJSON}: EmptySearchViewProps) {
76+
function EmptySearchView({similarSearchHash, type, hasResults, queryJSON, onScroll, contentContainerStyle}: EmptySearchViewProps) {
7477
const currentUserPersonalDetails = useCurrentUserPersonalDetails();
7578
const {typeMenuSections} = useSearchTypeMenuSections();
7679

@@ -98,6 +101,8 @@ function EmptySearchView({similarSearchHash, type, hasResults, queryJSON}: Empty
98101
groupPoliciesWithChatEnabled={groupPoliciesWithChatEnabled}
99102
hasSeenTour={hasSeenTour}
100103
queryJSON={queryJSON}
104+
onScroll={onScroll}
105+
contentContainerStyle={contentContainerStyle}
101106
/>
102107
</SearchScopeProvider>
103108
);
@@ -120,9 +125,12 @@ function EmptySearchViewContent({
120125
groupPoliciesWithChatEnabled,
121126
hasSeenTour,
122127
queryJSON,
128+
onScroll,
129+
contentContainerStyle,
123130
}: EmptySearchViewContentProps) {
124131
const {translate} = useLocalize();
125132
const styles = useThemeStyles();
133+
const isInLandscapeMode = useIsInLandscapeMode();
126134

127135
const illustrations = useMemoizedLazyIllustrations(['EmptyStateTravel']);
128136
const {showConfirmModal} = useConfirmModal();
@@ -434,13 +442,16 @@ function EmptySearchViewContent({
434442
}
435443

436444
return (
437-
<ScrollView
445+
<Animated.ScrollView
438446
showsVerticalScrollIndicator={false}
439-
contentContainerStyle={[styles.flexGrow1, styles.flexShrink0]}
447+
contentContainerStyle={[styles.flexGrow1, styles.flexShrink0, contentContainerStyle]}
448+
scrollEventThrottle={CONST.TIMING.MIN_SMOOTH_SCROLL_EVENT_THROTTLE}
449+
onScroll={onScroll}
440450
>
441451
<GenericEmptyStateComponent
442452
headerMedia={content.headerMedia}
443453
headerStyles={styles.emptyStateCardIllustrationContainer}
454+
minModalHeight={isInLandscapeMode ? 0 : undefined}
444455
title={content.title}
445456
titleStyles={content.titleStyles}
446457
subtitle={content.subtitle}
@@ -450,7 +461,7 @@ function EmptySearchViewContent({
450461
>
451462
{content.children}
452463
</GenericEmptyStateComponent>
453-
</ScrollView>
464+
</Animated.ScrollView>
454465
);
455466
}
456467

0 commit comments

Comments
 (0)