2.0.0 • Published 5 years ago

react-native-country-picker-modal v2.0.0

Weekly downloads
19,729
License
MIT
Repository
github
Last release
5 years ago
iOSAndroidWeb

Demo

Installation

$ yarn add react-native-country-picker-modal

Basic Usage

For more complete example open App.tsx

import React, { useState } from 'react'
import { View, Text, StyleSheet, PixelRatio, Switch } from 'react-native'
import CountryPicker from 'react-native-country-picker-modal'
import { CountryCode, Country } from './src/types'

const styles = StyleSheet.create({
  // ...
})

export default function App() {
  const [countryCode, setCountryCode] = useState<CountryCode>('FR')
  const [country, setCountry] = useState<Country>(null)
  const [withCountryNameButton, setWithCountryNameButton] = useState<boolean>(
    false,
  )
  const [withFlag, setWithFlag] = useState<boolean>(true)
  const [withEmoji, setWithEmoji] = useState<boolean>(true)
  const [withFilter, setWithFilter] = useState<boolean>(true)
  const [withAlphaFilter, setWithAlphaFilter] = useState<boolean>(false)
  const [withCallingCode, setWithCallingCode] = useState<boolean>(false)
  const onSelect = (country: Country) => {
    setCountryCode(country.cca2)
    setCountry(country)
  }
  return (
    <View style={styles.container}>
      <Text style={styles.welcome}>Welcome to Country Picker !</Text>
      <Option
        title='With country name on button'
        value={withCountryNameButton}
        onValueChange={setWithCountryNameButton}
      />
      <Option title='With flag' value={withFlag} onValueChange={setWithFlag} />
      <Option
        title='With emoji'
        value={withEmoji}
        onValueChange={setWithEmoji}
      />
      <Option
        title='With filter'
        value={withFilter}
        onValueChange={setWithFilter}
      />
      <Option
        title='With calling code'
        value={withCallingCode}
        onValueChange={setWithCallingCode}
      />
      <Option
        title='With alpha filter code'
        value={withAlphaFilter}
        onValueChange={setWithAlphaFilter}
      />
      <CountryPicker
        {...{
          countryCode,
          withFilter,
          withFlag,
          withCountryNameButton,
          withAlphaFilter,
          withCallingCode,
          withEmoji,
          onSelect,
        }}
        visible
      />
      <Text style={styles.instructions}>Press on the flag to open modal</Text>
      {country !== null && (
        <Text style={styles.data}>{JSON.stringify(country, null, 2)}</Text>
      )}
    </View>
  )
}

Props

  • countryCode: CountryCode
  • region?:Region
  • subregion?: Subregion
  • countryCodes?: CountryCode
  • theme?: Theme
  • translation?: TranslationLanguageCode
  • modalProps?: ModalProps
  • filterProps?: CountryFilterProps
  • flatListProps?: FlatListProps
  • withAlphaFilter?: boolean
  • withCallingCode?: boolean
  • withCurrency?: boolean
  • withEmoji?: boolean
  • withCountryNameButton?: boolean
  • withCurrencyButton?: boolean
  • withCallingCodeButton?: boolean
  • withFlagButton?: boolean
  • withCloseButton?: boolean
  • withFilter?: boolean
  • withFlag?: boolean
  • withModal?: boolean
  • visible?: boolean
  • containerButtonStyle?: StyleProp<ViewStyle>
  • renderFlagButton?(props: (FlagButton'props')): ReactNode (FlagButton props)
  • renderCountryFilter?(props: CountryFilter'props'): ReactNode (CountryFilter props is TextInputProps)
  • onSelect(country: Country): void (Country)
  • onOpen(): void
  • onClose(): void
  • closeButtonImage?: ImageSourcePropType
  • closeButtonStyle?: StyleProp
  • closeButtonImageStyle?: StyleProp
  • disableNativeModal?: boolean (you have to wrap your all app with CountryModalProvider)
  • preferredCountries: CountryCode preferred countries they appear first (withAlphaFilter must be false)

Dark theme example

A simple example to display a CountryPicker component with a dark theme.

import CountryPicker, { DARK_THEME } from 'react-native-country-picker-modal'

const MyDarkView = () => <CountryPicker theme={DARK_THEME} />

Dependencies

FAQ

Is it supported and tested both on android and iOS?

YES

Is the data that is populated inside the list saved offline once I install your package?

YES : It used the world-countries package and image is stored into json and base64.

Tiers lib using this lib

> Your project?

See also

Contribution

Questions

Feel free to contact me or create an issue

made with ♥

Licence

MIT

Hire an expert!

Looking for a ReactNative freelance expert with more than 12 years experience? Contact me from my website!

@borderfreefinancial/revoshowmobileui-test@borderfreefinancial/revoshowui-testsensesocial@infinitebrahmanuniverse/nolb-react-native-co@everything-registry/sub-chunk-2575storybook-componentsstorybook-compo@crownie/rnuikvell-app-uikvell-app-ui-testzigvy-expo-templateui-ambertrudenty-rn-sdk@crqlar/expo-sdk@flora8984461/react-native-phone-number-input@flashcoffee/fcuikit@foronered/react-native@kvell/kvell-app-ui@navid73/react-native-phone-number-input-rtl@nomada-sh/react-native-eyecandy@miriamjs/react-native-kit@mona-app/mona-rn-ui@kafudev/react-native-core@kafudev/react-native-shell@klumx/uiklu@raydeck/react-native-paper-phone-input@sawport/react-native-sdk@somosmona/mona-rn-ui@replyqa/rn-form-helpersminiappluxstayrnordering-ui-native-releaseordering-ui-native-ubanku-releaseorla-react-native-componentsordering-ui-react-nativepaga-con-btc-uireact-native-country-phone-number-inputreact-native-input-listrnshellrn-vayvayrn-phone-validation-albarakarn-phone-input-newrn-phone-no-inputreact-native-assentify-sdkreact-native-assentify-sdk-mojoreact-native-international-phone-number_omurreact-native-phone-entryreact-native-phone-input-with-refreact-native-phone-number-inputreact-native-phone-number-input-defaultreact-native-phone-number-input-forkreact-native-phone-number-input-forkedreact-native-phone-number-input-formattedreact-native-phone-auth-componentreact-native-phone-auth-component-v2safeplacereact-native-phone-number-input-tlcreact-native-phone-number-input-with-country-codereact-native-phone-number-input-with-maskreact-native-phone-number-input2react-native-phone-validatorinput-phone-rn-br@therightfit/react-native-phone-number-input@tisf/rn-providers@tisf/rn-screens@tisf/rn-uiad-rn-phone-input@zalastax/nolb-react-native-coassentify-sdk-react-nativebankerise-uico-react-native-international-phone-numberdhre-com-libdhre-ui-kitexpo-template-react-queryexpo-template-graphqlflyby-phone-number-inputfor-react-nativefluidlabsfrr-react-nativefrr-rngery-react-native-phone-number-input
2.0.0

5 years ago

1.11.0

5 years ago

1.10.0

5 years ago

1.9.8

5 years ago

1.9.7

5 years ago

1.9.6

5 years ago

1.9.5

5 years ago

1.9.4

5 years ago

1.9.3

5 years ago

1.9.2

5 years ago

1.9.1

5 years ago

1.9.0

5 years ago

1.8.1

6 years ago

1.8.0

6 years ago

1.7.2

6 years ago

1.7.1

6 years ago

1.7.0

6 years ago

1.6.0

6 years ago

1.5.2

6 years ago

1.5.1

6 years ago

1.5.0

6 years ago

1.4.1

6 years ago

1.4.0

6 years ago

1.3.0

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.8.0

6 years ago

0.7.1

6 years ago

0.7.0

6 years ago

0.6.2

7 years ago

0.6.0

7 years ago

0.5.1

7 years ago

0.5.0

7 years ago

0.4.0

7 years ago

0.3.0

8 years ago

0.3.0-rc1

8 years ago

0.2.10

8 years ago

0.2.8

8 years ago

0.2.7

9 years ago

0.2.6

9 years ago

0.2.5

9 years ago

0.2.4

9 years ago

0.2.3

9 years ago

0.2.2

9 years ago

0.2.0

9 years ago

0.1.6

9 years ago

0.1.5

9 years ago

0.1.2

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago

0.0.5

9 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago