@@ -3,8 +3,8 @@ import {Keyboard} from 'react-native';
33import HeaderWithBackButton from '@components/HeaderWithBackButton' ;
44import Modal from '@components/Modal' ;
55import ScreenWrapper from '@components/ScreenWrapper' ;
6- import SelectionList from '@components/SelectionListWithSections ' ;
7- import RadioListItem from '@components/SelectionListWithSections /RadioListItem' ;
6+ import SelectionList from '@components/SelectionList ' ;
7+ import RadioListItem from '@components/SelectionList/ListItem /RadioListItem' ;
88import useLocalize from '@hooks/useLocalize' ;
99import useThemeStyles from '@hooks/useThemeStyles' ;
1010import CONST from '@src/CONST' ;
@@ -31,11 +31,11 @@ function YearPickerModal({isVisible, years, currentYear = new Date().getFullYear
3131 const styles = useThemeStyles ( ) ;
3232 const { translate} = useLocalize ( ) ;
3333 const [ searchText , setSearchText ] = useState ( '' ) ;
34- const { sections , headerMessage} = useMemo ( ( ) => {
34+ const { data , headerMessage} = useMemo ( ( ) => {
3535 const yearsList = searchText === '' ? years : years . filter ( ( year ) => year . text ?. includes ( searchText ) ) ;
3636 return {
3737 headerMessage : ! yearsList . length ? translate ( 'common.noResultsFound' ) : '' ,
38- sections : [ { data : yearsList . sort ( ( a , b ) => b . value - a . value ) , indexOffset : 0 } ] ,
38+ data : yearsList . sort ( ( a , b ) => b . value - a . value ) ,
3939 } ;
4040 } , [ years , searchText , translate ] ) ;
4141
@@ -46,6 +46,18 @@ function YearPickerModal({isVisible, years, currentYear = new Date().getFullYear
4646 setSearchText ( '' ) ;
4747 } , [ isVisible ] ) ;
4848
49+ const textInputOptions = useMemo (
50+ ( ) => ( {
51+ label : translate ( 'yearPickerPage.selectYear' ) ,
52+ value : searchText ,
53+ onChangeText : ( text : string ) => setSearchText ( text . replaceAll ( CONST . REGEX . NON_NUMERIC , '' ) . trim ( ) ) ,
54+ headerMessage,
55+ maxLength : 4 ,
56+ inputMode : CONST . INPUT_MODE . NUMERIC ,
57+ } ) ,
58+ [ headerMessage , searchText , translate ] ,
59+ ) ;
60+
4961 return (
5062 < Modal
5163 type = { CONST . MODAL . MODAL_TYPE . RIGHT_DOCKED }
@@ -68,23 +80,18 @@ function YearPickerModal({isVisible, years, currentYear = new Date().getFullYear
6880 onBackButtonPress = { onClose }
6981 />
7082 < SelectionList
71- textInputLabel = { translate ( 'yearPickerPage.selectYear' ) }
72- textInputValue = { searchText }
73- textInputMaxLength = { 4 }
74- onChangeText = { ( text ) => setSearchText ( text . replaceAll ( CONST . REGEX . NON_NUMERIC , '' ) . trim ( ) ) }
75- inputMode = { CONST . INPUT_MODE . NUMERIC }
76- headerMessage = { headerMessage }
77- sections = { sections }
83+ data = { data }
84+ ListItem = { RadioListItem }
7885 onSelectRow = { ( option ) => {
7986 Keyboard . dismiss ( ) ;
8087 onYearChange ?.( option . value ) ;
8188 } }
82- initiallyFocusedOptionKey = { currentYear . toString ( ) }
83- showScrollIndicator
84- shouldStopPropagation
85- shouldUseDynamicMaxToRenderPerBatch
86- ListItem = { RadioListItem }
89+ textInputOptions = { textInputOptions }
90+ initiallyFocusedItemKey = { currentYear . toString ( ) }
91+ disableMaintainingScrollPosition
8792 addBottomSafeAreaPadding
93+ shouldStopPropagation
94+ showScrollIndicator
8895 />
8996 </ ScreenWrapper >
9097 </ Modal >
0 commit comments