Coder Social home page Coder Social logo

dbrab / react-native-country-codes-picker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from georgehop/react-native-country-codes-picker

0.0 0.0 0.0 155 KB

⚡ ⚡ ⚡This lib. provide multi lang. country picker with search functionality. Fully crossplatform and supported on React-native and expo. Didn't find your country ? Just add the required countries or locales and make a PR.⚡ ⚡ ⚡

Home Page: https://github.com/GeorgeHop/react-native-country-codes-picker

License: MIT License

JavaScript 100.00%

react-native-country-codes-picker's Introduction

react-native-country-codes-picker

⚡ ⚡ ⚡ This lib. provide multi lang. country picker with search functionality. Fully crossplatform and supported on React-native and expo. Didn't find your country ? Just add the required countries or locales and make a PR. ⚡ ⚡ ⚡

Coming soon 💪 🙏

  1. Custom list item rendering.
  2. Custom search input rendering.
  3. Picker types (modal, input). If you need input with search.
  4. Docs update/improve for the best user experience.
  5. TS Declarations.
  6. Animation improvements.

If you have something interesting ! Just write to us :)

❕ Installation ❕

expo: expo install react-native-country-codes-picker
npm: npm i react-native-country-codes-picker
yarn: yarn add react-native-country-codes-picker

Example

ezgif com-gif-maker (5)

Basic usage

import {CountryPicker} from "react-native-country-codes-picker/components/CountryPicker";

export default function App() {
  const [show, setShow] = useState(false);
  const [countryCode, setCountryCode] = useState('');

  return (
    <View style={styles.container}>
      <TouchableOpacity
        onPress={() => setShow(true)}
        style={{
            width: '80%',
            height: 60,
            backgroundColor: 'black',
            padding: 10,
        }}
      >
        <Text style={{
            color: 'white',
            fontSize: 20
        }}>
            {countryCode}
        </Text>
      </TouchableOpacity>

      // For showing picker just put show state to show prop
      <CountryPicker
        show={show}
        // when picker button press you will get the country object with dial code
        pickerButtonOnPress={(item) => {
          setCountryCode(item.dial_code);
          setShow(false);
        }}
      />
    </View>
  );
}

Props

Below are the props you can pass to the React Component.

Prop Type Default Example Description
show boolean This prop using for displaying the modal. Put your show state here.
pickerButtonOnPress function (country) => setCode(country.dial_code) Put your function/functions here for getting country data from picker.
inputPlaceholder string inputPlaceholder={'Your placeholder'} If you need a custom placeholder for your input you may need this prop.
searchMessage string searchMessage={'Some search message here'} If you want to customize search message just use this prop.
lang string 'en' lang={'pl'} If you need to change the lang. just put one of supported lang. Or if you didn't find required lang just add them and make a PR :)
enableModalAvoiding boolean false enableModalAvoiding={true} Is modal should avoid keyboard ? On android to work required to use with androidWindowSoftInputMode with value pan, by default android will avoid keyboard by itself
androidWindowSoftInputMode string androidWindowSoftInputMode={'pan'} Basicaly android avoid keyboard by itself, if you want to use custom avoiding you may use this prop
style Object style={{yoursStylesHere}} If you want to change styles for component you probably need this props. You can check the styling part below.

❕ Also you can use all other FlatList and TextInput props if you need. ❕

Styling

<CountryPicker
    show={show}
    lang={'cz'}
    style={{
        // Styles for whole modal [View]
        modal: {
            height: 500,
            backgroundColor: 'red'
        },
        // Styles for input [TextInput]
        textInput: {
              height: 80,
              borderRadius: 0,
        },
        // Styles for country button [TouchableOpacity]
        countryButtonStyles: {
              height: 80
        },
        // Styles for search message [Text]
        searchMessageText: {

        },
        // Flag styles [Text]
        flag: {

        },
        // Dial code styles [Text]
        dialCode: {

        },
        // Country name styles [Text]
        countryName: {

        }
    }}
    pickerButtonOnPress={(item) => {
        setCountryCode(item.dial_code);
        setShow(false);
    }}
/>

🎌 Supported langs. 🎌

  1. cz.
  2. ua.
  3. ru.
  4. en.
  5. pl.

You can add your lang. if you need !!! But after that make a PR please, it will help other people.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.