-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
cristipaval
merged 23 commits into
Expensify:main
from
lukemorawski:searchpage_list_refactor
Jan 10, 2024
Merged
SearchPage list refactor #33080
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 a999180
list refactor
lukemorawski 71b5056
moved useDebouncedState hook to an independent file
lukemorawski 186bfb2
removed comment and unused param
lukemorawski e859ff1
removed old SearchPage component
lukemorawski ba39519
Merge branch 'main' into searchpage_list_refactor
lukemorawski d4c611f
Merge branch 'main' into searchpage_list_refactor
lukemorawski ad06aff
fixed theme hooks import
lukemorawski f3eceb7
Merge remote-tracking branch 'origin/searchpage_list_refactor' into s…
lukemorawski d6a29a5
Merge branch 'main' into searchpage_list_refactor
lukemorawski ef63c51
move to usePersonalDetails hook
lukemorawski af685f8
moved footer to seperate component
lukemorawski aba386f
moved searchRendered function outside of component scope
lukemorawski f013c6b
changed debouncedstate default delay value to val from const
lukemorawski 3407d73
rename perf function
lukemorawski c0c09a3
fallback to global empty array
lukemorawski 2c80e11
search page footer instance
lukemorawski b10fb90
Merge branch 'main' into searchpage_list_refactor
lukemorawski cd60062
removed old component
lukemorawski 4d09449
const migration
lukemorawski ad41ffb
SectionList wrapper opacity fix to show skeleton
lukemorawski 1a9907c
Merge branch 'main' into searchpage_list_refactor
lukemorawski 6c2aa51
merge with main fixes
lukemorawski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]}> | ||
<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; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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