1.0.1 • Published 2 years ago

rn-country-picker v1.0.1

Weekly downloads
29
License
MIT
Repository
github
Last release
2 years ago

rn-country-picker

Country picker with Country Code and Flag for react native support both platform IOs and android

Features

  1. Light weight country picker npm.
  2. Cross platform compatibility android and ios both.
  3. Search country using country code or country code.
  4. Support multiple language search and list items.
  5. Dynamically change dropdown, search and back button images.
  6. Customizable search bar style and text colors.
  7. Change animation(Slide, fade, none).

Installation

npm i rn-country-picker

Usage

import React, { useState } from "react";
import { StyleSheet, Text, View } from "react-native";
import CountryPicker from "rn-country-picker";

const App = () => {
	const [countryCode, setCountryCode] = useState<string>("91");

	const selectedValue = (value: string) => {
		setCountryCode(value);
	};

	return (
		<View style={styles.container}>
			<Text style={styles.titleText}>React Native Country Picker</Text>
			<CountryPicker
				disable={false}
				animationType={"slide"}
				language="en"
				containerStyle={styles.pickerStyle}
				pickerTitleStyle={styles.pickerTitleStyle}
				dropDownImage={require("./res/ic_drop_down.png")}
				selectedCountryTextStyle={styles.selectedCountryTextStyle}
				countryNameTextStyle={styles.countryNameTextStyle}
				pickerTitle={"Country Picker"}
				searchBarPlaceHolder={"Search......"}
				hideCountryFlag={false}
				hideCountryCode={false}
				searchBarStyle={styles.searchBarStyle}
				backButtonImage={require("./res/ic_back_black.png")}
				searchButtonImage={require("./res/ic_search.png")}
				countryCode={"1"}
				selectedValue={selectedValue}
			/>
		</View>
	);
};
export default App;

const styles = StyleSheet.create({
	container: {
		flex: 1,
		justifyContent: "center",
		alignItems: "center",
		backgroundColor: "#F5FCFF",
	},
	titleText: {
		color: "#000",
		fontSize: 25,
		marginBottom: 25,
		fontWeight: "bold",
	},
	pickerTitleStyle: {
		justifyContent: "center",
		flexDirection: "row",
		alignSelf: "center",
		fontWeight: "bold",
	},
	pickerStyle: {
		height: 54,
		width: 150,
		marginVertical: 10,
		borderColor: "#303030",
		alignItems: "center",
		marginHorizontal: 10,
		padding: 10,
		backgroundColor: "white",
		borderRadius: 5,
		borderWidth: 2,
		fontSize: 16,
		color: "#000",
	},
	selectedCountryTextStyle: {
		paddingLeft: 5,
		color: "#000",
		textAlign: "right",
	},

	countryNameTextStyle: {
		paddingLeft: 10,
		color: "#000",
		textAlign: "right",
	},

	searchBarStyle: {
		flex: 1,
	},
});

Properties

PropDefaultTypeDescriptionRequired/Optional
countryCode-stringDefault and selected country codeRequired
pickerTitle-stringChange picker titleRequired
pickerTitleStyle-stringCustomize picker title styleRequired
searchBarPlaceHolder-stringChange search bar placeholderOptional
searchBarStyle-objectCustomize search bar text input styleOptional
searchBarContainerStyle-objectCustomize search bar container styleOptional
containerStyle-objectCustomize picker styleRequired
countryNameTextStyle-objectCustomize country name text style(List View)Optional
selectedCountryTextStyle-objectCustomize selected label text styleOptional
dropDownImageStyle-objectChange dropdown arrow styleOptional
countryFlagStyle-objectCustomize flag styleOptional
searchButtonImage-png/jpgAdd custom search imageOptional
backButtonImage-png/jpgAdd custom back button imageOptional
dropDownImage-png/jpgAdd custom drop down imageOptional
selectedValue-functioncallback function received value from list selectionRequired
animationType-string slide,none,fadeChange Modal AnimationOptional
hideCountryCode-boolhide country code from component only show flagOptional
hideCountryFlag-boolhide country flag from component and List only show codeOptional
disable-boolDisable picker if you show default value and no need to changeOptional
languageenstringChange the language of listOptional
1.0.1

2 years ago

1.0.0

2 years ago

0.0.13

2 years ago

0.0.12

3 years ago

0.0.11

4 years ago

0.0.10

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago