Skip to content
Merged
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, {useCallback, useMemo, useState} from 'react';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import ScreenWrapper from '@components/ScreenWrapper';
import SelectionList from '@components/SelectionListWithSections';
import RadioListItem from '@components/SelectionListWithSections/RadioListItem';
import SelectionList from '@components/SelectionList';
import RadioListItem from '@components/SelectionList/ListItem/RadioListItem';
import useLocalize from '@hooks/useLocalize';
import Navigation from '@libs/Navigation/Navigation';
import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types';
Expand Down Expand Up @@ -39,7 +39,6 @@ function CountrySelectionPage({route}: CountrySelectionPageProps) {
);

const searchResults = searchOptions(searchValue, countries);
const headerMessage = searchValue.trim() && !searchResults.length ? translate('common.noResultsFound') : '';

const selectCountry = useCallback(
(option: Option) => {
Expand All @@ -56,6 +55,16 @@ function CountrySelectionPage({route}: CountrySelectionPageProps) {
[route.params.backTo],
);

const textInputOptions = useMemo(
() => ({
headerMessage: searchValue.trim() && !searchResults.length ? translate('common.noResultsFound') : '',
label: translate('common.country'),
value: searchValue,
onChangeText: setSearchValue,
}),
[searchResults.length, searchValue, translate],
);

return (
<ScreenWrapper
testID={CountrySelectionPage.displayName}
Expand All @@ -72,16 +81,12 @@ function CountrySelectionPage({route}: CountrySelectionPageProps) {
/>

<SelectionList
headerMessage={headerMessage}
textInputLabel={translate('common.country')}
textInputValue={searchValue}
sections={[{data: searchResults}]}
data={searchResults}
ListItem={RadioListItem}
onSelectRow={selectCountry}
textInputOptions={textInputOptions}
initiallyFocusedItemKey={currentCountry}
shouldSingleExecuteRowSelect
onChangeText={setSearchValue}
initiallyFocusedOptionKey={currentCountry}
shouldUseDynamicMaxToRenderPerBatch
addBottomSafeAreaPadding
/>
</ScreenWrapper>
Expand Down
Loading