GithubHelp home page GithubHelp logo

aleksandriukas / react-native-actions-sheet-picker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bur0/react-native-actions-sheet-picker

0.0 0.0 0.0 4.65 MB

A React Native component that provides a filterable select dropdown/picker.

Home Page: https://www.npmjs.com/package/react-native-actions-sheet-picker

License: MIT License

Shell 0.75% JavaScript 7.36% Ruby 2.92% C 0.52% Objective-C 16.15% Java 31.26% TypeScript 40.71% Swift 0.35%

react-native-actions-sheet-picker's Introduction

React Native Actions Sheet Picker

A React Native component that provides a filterable select dropdown/picker.

Preview

Installation Guide

yarn add react-native-actions-sheet-picker

or

npm install react-native-actions-sheet-picker

Usage

import React, { useState, useMemo, useEffect } from 'react';

import { StyleSheet, Text, TouchableOpacity, SafeAreaView } from 'react-native';
import { Picker, onOpen } from 'react-native-actions-sheet-picker';

/*
 **Example data:
 */
import countries from './countries.json';

export default function App() {
  const [data, setData] = useState([]);
  const [selected, setSelected] = useState(undefined);
  const [query, setQuery] = useState('');

  useEffect(() => {
    setData(countries);
  }, []);

  /*
   **Example filter function
   * @param {string} filter
   */
  const filteredData = useMemo(() => {
    if (data && data.length > 0) {
      return data.filter((item) =>
        item.name
          .toLocaleLowerCase('en')
          .includes(query.toLocaleLowerCase('en'))
      );
    }
  }, [data, query]);

  /*
   **Input search
   *@param {string} text
   */
  const onSearch = (text) => {
    setQuery(text);
  };

  return (
    <SafeAreaView style={styles.container}>
      <TouchableOpacity
        style={styles.button}
        onPress={() => {
          onOpen('country');
        }}
      >
        <Text>Open ActionSheet</Text>
      </TouchableOpacity>
      <Text style={{ padding: 10 }}>Chosen : {JSON.stringify(selected)}</Text>
      <Picker
        id="country"
        data={filteredData}
        inputValue={query}
        searchable={true}
        label="Select Country"
        setSelected={setSelected}
        onSearch={onSearch}
      />
    </SafeAreaView>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
  },
  button: {
    backgroundColor: '#8B93A5',
    padding: 10,
    borderRadius: 6,
    marginTop: 50,
  },
});

Options

Properties Type Description Default
id
*required
string A unique id for the ActionSheet
data array Array of list items []
inputValue string The value to show for the text input.
searchable boolean Searchable state false
loading boolean Loading state false
label string Flatlist label
height string ActionSheet height Dimensions.get('window').height * 0.5
closeText string Close text "Close"
placeholderText string Placeholder text "Search"
noDataFoundText string No data found text "No Data Found."
placeholderTextColor string Placeholder text color #8B93A5
setSelected function Selected function
onSearch function Textinput search function
renderListItem function Render List item

Method

Properties Type Description
onOpen function SheetManager show
onClose function SheetManager hide

Core Props of using packages

Properties Type Description
actionsSheetProps object react-native-actions-sheet
flatListProps object FlatListProps
searchInputProps object TextInputProps

Roadmap

  • Multiple select
  • Issue 3 (Bur0#3)
  • Issue 4 (Bur0#4)
  • renderListItem | props
  • Selected highlight

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

react-native-actions-sheet-picker's People

Contributors

bur0 avatar artiomtr avatar

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.