0.4.6 • Published 5 days ago

rn-modal-picker v0.4.6

Weekly downloads
240
License
ISC
Repository
github
Last release
5 days ago
AndroidiOSWeb

Features

  1. Easy to use.
  2. Cross-platform compatibility Android, iOS and Web.
  3. Hide and show search bar.
  4. Dynamically change dropdown and search image.
  5. Customize font size, font color and picker style.
  6. Change animation(Slide, fade, none)

Installation

Step 1 Install

npm i rn-modal-picker

Usage

import React, { useState } from "react";
import { Platform, StyleSheet, Text, View } from "react-native";
import ModalPicker from "rn-modal-picker";

const dataSource = [
  {
    id: 1,
    name: "Afghanistan",
  },
  {
    id: 2,
    name: "Bahrain",
  },
  {
    id: 3,
    name: "Canada",
  },
  {
    id: 4,
    name: "Denmark",
  },
  {
    id: 5,
    name: "Egypt",
  },
  {
    id: 6,
    name: "France",
  },
  {
    id: 7,
    name: "Greece",
  },
  {
    id: 8,
    name: "Hong Kong",
  },
  {
    id: 9,
    name: "India",
  },
  {
    id: 10,
    name: "Japan",
  }
];
const App = () => {
  const [value, setValue] = useState("");

  return (
    <View style={styles.container}>
      <Text style={styles.titleText}>React Native Modal Picker</Text>

      <ModalPicker
        value={value}
        data={dataSource}
        animationType={"slide"}
        pickerContainerStyle={styles.pickerStyle}
        dropDownIcon={require("./res/ic_drop_down.png")}
        selectedTextStyle={styles.selectedTextStyle}
        listTextStyle={styles.listTextStyle}
        placeHolderText={"Please select country"}
        searchBarPlaceHolder={"Search......"}
        searchBarPlaceHolderColor={"grey"}
        placeHolderTextColor={"black"}
        searchBarStyle={styles.searchBarStyle}
        searchClearIcon={require("./res/ic_close.png")}
        onChange={(value) => {
          setValue(value);
        }}
      />
    </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",
  },
  pickerStyle: {
    height: 50,
    width: "100%",
    marginVertical: 10,
    borderColor: "#303030",
    alignItems: "center",
    alignSelf: "center",
    padding: 10,
    backgroundColor: "white",
    borderRadius: 5,
    borderWidth: 1.5,
    fontSize: 16,
    color: "#000",
  },
  selectedTextStyle: {
    paddingLeft: 5,
    color: "#000",
    textAlign: "right",
  },
  listTextStyle: {
    color: "#000",
    textAlign: "right",
  },

  searchBarStyle: {
    margin: 10,
    padding: 10,
    flexDirection: "row",
    height: 45,
    shadowOpacity: 1.0,
    shadowRadius: 2,
    shadowOffset: {
      width: 1,
      height: 1,
    },
    backgroundColor: "rgba(255,255,255,1)",
    shadowColor: Platform.OS === "ios" ? "rgba(0,0,0,0.3)" : "rgba(0,0,0,1)",
    borderRadius: 10,
    elevation: 5,
  },
});

Properties

PropDefaultTypeDescriptionRequired/Optional
data[]arrayArray of objects with a unique id and nameRequired
hideSearchBarfalseboolShow and hide search barOptional
value-stringSet selected value otherwise its blank $ use for default valueOptional
placeHolderText-stringUse to Show place holder hint textRequired
pickerContainerStyle-objectCustomize picker styleRequired
listTextStyle-objectCustomize list item text styleOptional
placeHolderTextColor-objectCustomize placeholder text colorOptional
itemSeparatorStyle-objectStyle for Horizontal Line between itemOptional
selectedTextStyle-objectCustomize selected text styleOptional
searchBarStyle-objectCustomize Search bar Container styleOptional
onChange-functioncallback function received value from list selectionRequired
animationType-string slide,none,fadeChange Modal AnimationOptional
disable-boolDisable picker if you show default value and no need to changeOptional
searchBarPlaceHolder-stringSearch bar place holder textOptional
searchBarPlaceHolderColor-color codeAdd color codeOptional
dropDownIconStyle-objectChange drop down icon style colorOptional
searchClearIcon-png/jpgChange search bar text clear icon styleOptional
searchIcon-png/jpgChange search bar icon style colorOptional
dropDownIcon-png/jpgChange picker drop down iconOptional
0.4.5

6 days ago

0.4.6

5 days ago

0.3.2

3 years ago

0.3.1

3 years ago

0.3.0

4 years ago

0.2.9

4 years ago

0.2.8

4 years ago

0.2.7

5 years ago

0.2.6

5 years ago

0.2.5

5 years ago

0.2.4

5 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.9

5 years ago

0.1.8

5 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.0

5 years ago

0.0.9

5 years ago

0.0.8

5 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