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

SearchPage list refactor #33080

Merged
merged 23 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
97fbe84
refactor to functional component
lukemorawski Dec 5, 2023
a999180
list refactor
lukemorawski Dec 14, 2023
71b5056
moved useDebouncedState hook to an independent file
lukemorawski Dec 14, 2023
186bfb2
removed comment and unused param
lukemorawski Dec 14, 2023
e859ff1
removed old SearchPage component
lukemorawski Dec 14, 2023
ba39519
Merge branch 'main' into searchpage_list_refactor
lukemorawski Dec 14, 2023
d4c611f
Merge branch 'main' into searchpage_list_refactor
lukemorawski Dec 14, 2023
ad06aff
fixed theme hooks import
lukemorawski Dec 18, 2023
f3eceb7
Merge remote-tracking branch 'origin/searchpage_list_refactor' into s…
lukemorawski Dec 18, 2023
d6a29a5
Merge branch 'main' into searchpage_list_refactor
lukemorawski Dec 18, 2023
ef63c51
move to usePersonalDetails hook
lukemorawski Dec 18, 2023
af685f8
moved footer to seperate component
lukemorawski Dec 18, 2023
aba386f
moved searchRendered function outside of component scope
lukemorawski Dec 18, 2023
f013c6b
changed debouncedstate default delay value to val from const
lukemorawski Dec 19, 2023
3407d73
rename perf function
lukemorawski Dec 19, 2023
c0c09a3
fallback to global empty array
lukemorawski Dec 19, 2023
2c80e11
search page footer instance
lukemorawski Dec 19, 2023
b10fb90
Merge branch 'main' into searchpage_list_refactor
lukemorawski Dec 19, 2023
cd60062
removed old component
lukemorawski Dec 19, 2023
4d09449
const migration
lukemorawski Dec 19, 2023
ad41ffb
SectionList wrapper opacity fix to show skeleton
lukemorawski Jan 5, 2024
1a9907c
Merge branch 'main' into searchpage_list_refactor
lukemorawski Jan 5, 2024
6c2aa51
merge with main fixes
lukemorawski Jan 5, 2024
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
2 changes: 2 additions & 0 deletions src/components/SelectionList/BaseSelectionList.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ function BaseSelectionList({
textInputLabel = '',
textInputPlaceholder = '',
textInputValue = '',
textInputHint = '',
textInputMaxLength,
inputMode = CONST.INPUT_MODE.TEXT,
onChangeText,
Expand Down Expand Up @@ -414,6 +415,7 @@ function BaseSelectionList({
}}
label={textInputLabel}
accessibilityLabel={textInputLabel}
hint={textInputHint}
role={CONST.ROLE.PRESENTATION}
value={textInputValue}
placeholder={textInputPlaceholder}
Expand Down
34 changes: 34 additions & 0 deletions src/hooks/useDebouncedState.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import {debounce} from 'lodash';
import {useEffect, useRef, useState} from 'react';

/**
* A React hook that provides a state and its debounced version.
*
* @param initialValue - The initial value of the state.
* @param delay - The debounce delay in milliseconds. Defaults to 100ms.
* @returns A tuple containing:
* - The current state value.
* - The debounced state value.
* - A function to set both the current and debounced state values.
*
* @template T The type of the state value.
*
* @example
* const [value, debouncedValue, setValue] = useDebouncedState<string>("", 300);
*/
function useDebouncedState<T>(initialValue: T, delay = 100): [T, T, (value: T) => void] {
const [value, setValue] = useState(initialValue);
const [debouncedValue, setDebouncedValue] = useState(initialValue);
const debouncedSetDebouncedValue = useRef(debounce(setDebouncedValue, delay)).current;

useEffect(() => () => debouncedSetDebouncedValue.cancel(), [debouncedSetDebouncedValue]);

const handleSetValue = (newValue: T) => {
setValue(newValue);
debouncedSetDebouncedValue(newValue);
};

return [value, debouncedValue, handleSetValue];
}

export default useDebouncedState;
241 changes: 0 additions & 241 deletions src/pages/SearchPage.js

This file was deleted.

59 changes: 59 additions & 0 deletions src/pages/SearchPage/SearchPageFooter.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import React from 'react';
import {View} from 'react-native';
import Icon from '@components/Icon';
import {Info} from '@components/Icon/Expensicons';
import {PressableWithoutFeedback} from '@components/Pressable';
import Text from '@components/Text';
import useLocalize from '@hooks/useLocalize';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import Navigation from '@libs/Navigation/Navigation';
import CONST from '@src/CONST';
import ROUTES from '@src/ROUTES';

function SearchPageFooter() {
const themeStyles = useThemeStyles();
const theme = useTheme();
const {translate} = useLocalize();

return (
<View style={[themeStyles.pb5, themeStyles.flexShrink0]}>
Copy link
Member

Choose a reason for hiding this comment

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

The footer has a larger padding than what staging has

image

<PressableWithoutFeedback
onPress={() => {
Navigation.navigate(ROUTES.REFERRAL_DETAILS_MODAL.getRoute(CONST.REFERRAL_PROGRAM.CONTENT_TYPES.REFER_FRIEND));
}}
style={[
themeStyles.p5,
themeStyles.w100,
themeStyles.br2,
themeStyles.highlightBG,
themeStyles.flexRow,
themeStyles.justifyContentBetween,
themeStyles.alignItemsCenter,
{gap: 10},
]}
accessibilityLabel="referral"
role={CONST.ACCESSIBILITY_ROLE.BUTTON}
>
<Text>
{translate(`referralProgram.${CONST.REFERRAL_PROGRAM.CONTENT_TYPES.REFER_FRIEND}.buttonText1`)}
<Text
color={theme.success}
style={themeStyles.textStrong}
>
{translate(`referralProgram.${CONST.REFERRAL_PROGRAM.CONTENT_TYPES.REFER_FRIEND}.buttonText2`)}
</Text>
</Text>
<Icon
src={Info}
height={20}
width={20}
/>
</PressableWithoutFeedback>
</View>
);
}

SearchPageFooter.displayName = 'SearchPageFooter';

export default SearchPageFooter;
Loading
Loading