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

added Section titles in carret when popularCountries are present. #80

Merged
Merged
Show file tree
Hide file tree
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
41 changes: 27 additions & 14 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {
getFlagTextStyle,
getInputStyle,
} from './utils/getStyles';
import styles from "./styles";

const PhoneInput = forwardRef(
(
Expand All @@ -59,6 +60,8 @@ const PhoneInput = forwardRef(
showOnly,
excludedCountries,
popularCountries,
popularCountriesSectionTitle,
restOfCountriesSectionTitle,
modalSearchInputPlaceholder,
modalSearchInputPlaceholderTextColor,
modalSearchInputSelectionColor,
Expand Down Expand Up @@ -433,21 +436,31 @@ const PhoneInput = forwardRef(
excludedCountries={excludedCountries}
popularCountries={popularCountries}
ListHeaderComponent={({ countries, lang, onPress }) => {
return countries.map((country, index) => {
return (
<CountryButton
key={index}
item={country}
name={country?.name?.[lang || 'en']}
onPress={() => onPress(country)}
style={getCountryPickerStyle(
theme,
modalHeight,
modalStyles
return (
<View>
{popularCountriesSectionTitle &&(
<Text>{popularCountriesSectionTitle}</Text>
)}
/>
);
});
{countries.map((country, index) => {
return (
<CountryButton
key={index}
item={country}
name={country?.name?.[lang || 'en']}
onPress={() => onPress(country)}
style={getCountryPickerStyle(
theme,
modalHeight,
modalStyles
)}
/>
);
})}
{restOfCountriesSectionTitle &&(
<Text style={styles.sectionTitle}>{restOfCountriesSectionTitle}</Text>
)}
</View>
)
}}
/>
) : null}
Expand Down
2 changes: 2 additions & 0 deletions lib/interfaces/phoneInputProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ interface BasePhoneInput extends TextInputProps {
showOnly?: Array<ICountryCca2>;
excludedCountries?: Array<ICountryCca2>;
popularCountries?: Array<ICountryCca2>;
popularCountriesSectionTitle?:string,
restOfCountriesSectionTitle?:string,
modalSearchInputPlaceholder?: string;
modalSearchInputPlaceholderTextColor?: string;
modalSearchInputSelectionColor?: string;
Expand Down
5 changes: 4 additions & 1 deletion lib/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,10 @@ const styles = StyleSheet.create({
...inputBase,
color: '#F3F3F3',
},

sectionTitle:{
marginTop: 10,
marginBottom: 10,
},
lightCountryPicker: {
modal: {
backgroundColor: '#FFFFFF',
Expand Down