-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Migrate YearPickerModal to a @react-navigation modal screen #91106
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
Open
trasnake87
wants to merge
29
commits into
Expensify:main
Choose a base branch
from
trasnake87:yearpicker-rnav-90469
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
1a5dac9
Migrate YearPickerModal to a @react-navigation modal screen
trasnake87 883930e
Make YearSelector dynamic route reachable from any CalendarPicker host
trasnake87 426a100
Use Modal.closeTop for popover hosts and useId for the fallback conte…
trasnake87 cd94220
Require pickerContextID on CalendarPicker and add YEAR_SELECTOR getRoute
trasnake87 46ff704
Use createElement in CalendarPickerForTest wrapper to satisfy jsx-pro…
trasnake87 b8623b2
Keep date picker mounted while year selector is open on web wide-screen
trasnake87 4ddd719
Fix CalendarPicker unit test for the new root-navigation-state read
trasnake87 d831e3a
Address review: visibilityHidden on year-picker hide + getPlatform() …
trasnake87 4b66982
Merge remote-tracking branch 'upstream/main' into yearpicker-rnav-90469
trasnake87 57f2969
Hide whole year-picker host popover instead of inner calendar; drop r…
trasnake87 c9c2bea
Mock useRootNavigationState in IOU/time confirmation tests that rende…
trasnake87 fc49180
Merge main into yearpicker-rnav-90469
trasnake87 b1d1f4c
Preserve search date-filter view state across the year-selector round…
trasnake87 d62b9db
DOB date picker: keep popover mounted + hide CalendarPicker while yea…
trasnake87 b0bae95
Merge branch 'main' of https://github.com/Expensify/App into yearpick…
trasnake87 c623abb
Merge branch 'main' of https://github.com/Expensify/App into yearpick…
trasnake87 942fc3b
Make kept-mounted date popovers pointer-transparent for the year-sele…
trasnake87 cb2dea4
Keep date pickers open across the year-selector round-trip; address r…
trasnake87 dcd2401
Merge remote-tracking branch 'upstream/main' into yearpicker-rnav-90469
trasnake87 40748ec
Fix CI typecheck + spellcheck on the merged branch
trasnake87 3bb3df6
Merge remote-tracking branch 'upstream/main' into yearpicker-rnav-90469
trasnake87 392638d
Clear search date-modifier breadcrumb on sub-view exit
trasnake87 1754931
Coordinate year-selector hide through HiddenForOverlayContext
trasnake87 dd63b95
Merge main (Oxfmt import-order conflicts; adopt main's unwrapped dyna…
trasnake87 fb8a7b3
Restore imports dropped in the main merge
trasnake87 ff539d4
Remove imports resurrected by the merge; satisfy required swipeThresh…
trasnake87 c1ca658
Oxfmt the pre-migration PR files
trasnake87 5415295
Oxfmt remaining test file
trasnake87 723ffd0
Align modal context test with tightened lint rules
trasnake87 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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
100 changes: 100 additions & 0 deletions
100
src/components/DatePicker/CalendarPicker/DynamicYearSelectorPage.tsx
This file contains hidden or 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,100 @@ | ||
| import HeaderWithBackButton from '@components/HeaderWithBackButton'; | ||
| import ScreenWrapper from '@components/ScreenWrapper'; | ||
| import SelectionList from '@components/SelectionList'; | ||
| import SingleSelectListItem from '@components/SelectionList/ListItem/SingleSelectListItem'; | ||
|
|
||
| import useDynamicBackPath from '@hooks/useDynamicBackPath'; | ||
| import useLocalize from '@hooks/useLocalize'; | ||
| import useThemeStyles from '@hooks/useThemeStyles'; | ||
|
|
||
| import {setCalendarPickerSelectedYear} from '@libs/actions/CalendarPicker'; | ||
| import Navigation from '@libs/Navigation/Navigation'; | ||
| import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types'; | ||
|
|
||
| import type {SettingsNavigatorParamList} from '@navigation/types'; | ||
|
|
||
| import CONST from '@src/CONST'; | ||
| import {DYNAMIC_ROUTES} from '@src/ROUTES'; | ||
| import type SCREENS from '@src/SCREENS'; | ||
|
|
||
| import React, {useMemo, useState} from 'react'; | ||
| import {Keyboard} from 'react-native'; | ||
|
|
||
| import type CalendarPickerListItem from './types'; | ||
|
|
||
| type DynamicYearSelectorPageProps = PlatformStackScreenProps<SettingsNavigatorParamList, typeof SCREENS.SETTINGS.DYNAMIC_YEAR_SELECTOR>; | ||
|
|
||
| function DynamicYearSelectorPage({route}: DynamicYearSelectorPageProps) { | ||
| const styles = useThemeStyles(); | ||
| const {translate} = useLocalize(); | ||
| const backPath = useDynamicBackPath(DYNAMIC_ROUTES.YEAR_SELECTOR.path); | ||
|
|
||
| const {contextID} = route.params; | ||
| const currentYear = Number(route.params.currentYear) || new Date().getFullYear(); | ||
| const minYear = Number(route.params.minYear) || CONST.CALENDAR_PICKER.MIN_YEAR; | ||
| const maxYear = Number(route.params.maxYear) || CONST.CALENDAR_PICKER.MAX_YEAR; | ||
|
|
||
| const [searchText, setSearchText] = useState(''); | ||
|
|
||
| const years: CalendarPickerListItem[] = useMemo( | ||
| () => | ||
| Array.from({length: maxYear - minYear + 1}, (value, index) => index + minYear).map((year) => ({ | ||
| text: year.toString(), | ||
| value: year, | ||
| keyForList: year.toString(), | ||
| isSelected: year === currentYear, | ||
| })), | ||
| [minYear, maxYear, currentYear], | ||
| ); | ||
|
|
||
| const {data, headerMessage} = useMemo(() => { | ||
| const yearsList = searchText === '' ? years : years.filter((year) => year.text?.includes(searchText)); | ||
| return { | ||
| headerMessage: !yearsList.length ? translate('common.noResultsFound') : '', | ||
| data: yearsList.sort((a, b) => b.value - a.value), | ||
| }; | ||
| }, [years, searchText, translate]); | ||
|
|
||
| const textInputOptions = useMemo( | ||
| () => ({ | ||
| label: translate('yearPickerPage.selectYear'), | ||
| value: searchText, | ||
| onChangeText: (text: string) => setSearchText(text.replaceAll(CONST.REGEX.NON_NUMERIC, '').trim()), | ||
| headerMessage, | ||
| maxLength: 4, | ||
| inputMode: CONST.INPUT_MODE.NUMERIC, | ||
| }), | ||
| [headerMessage, searchText, translate], | ||
| ); | ||
|
|
||
| return ( | ||
| <ScreenWrapper | ||
| style={[styles.pb0]} | ||
| includePaddingTop={false} | ||
| enableEdgeToEdgeBottomSafeAreaPadding | ||
| testID="DynamicYearSelectorPage" | ||
| > | ||
| <HeaderWithBackButton | ||
| title={translate('yearPickerPage.year')} | ||
| onBackButtonPress={() => Navigation.goBack(backPath)} | ||
| /> | ||
| <SelectionList | ||
| data={data} | ||
| ListItem={SingleSelectListItem} | ||
| onSelectRow={(option) => { | ||
| Keyboard.dismiss(); | ||
| setCalendarPickerSelectedYear(contextID, option.value); | ||
| Navigation.goBack(backPath); | ||
| }} | ||
| textInputOptions={textInputOptions} | ||
| initiallyFocusedItemKey={currentYear.toString()} | ||
| disableMaintainingScrollPosition | ||
| addBottomSafeAreaPadding | ||
| shouldStopPropagation | ||
| showScrollIndicator | ||
| /> | ||
| </ScreenWrapper> | ||
| ); | ||
| } | ||
|
|
||
| export default DynamicYearSelectorPage; |
109 changes: 0 additions & 109 deletions
109
src/components/DatePicker/CalendarPicker/YearPickerModal.tsx
This file was deleted.
Oops, something went wrong.
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.
Add a getRoute handler here to add queryParams.
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.
Done in cd94220 — added a
getRouteonYEAR_SELECTORthat takes{contextID, currentYear, minYear, maxYear}and goes throughgetUrlWithParams('year-selector', …)so encoding stays in one place and matches the declaredqueryParams.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.
Done in cd94220 —
YEAR_SELECTORnow has a typedgetRoute({contextID, currentYear, minYear, maxYear})handler that builds the query params viagetUrlWithParams.