Git Product home page Git Product logo

react-native-picklist's Introduction

react-native-picklist

npm version Build Status

中文说明

This is a picklist page. It supports:

  • Single Level or Multiple Level data.
  • Single Select or Multiple Select.
  • Show or Hide the internal components.
  • Customize the UI component.
  • Search in the data automaticlly.
  • Section style page.

ScreenShots

Same UI on Android.

Install

Install by Yarn:

yarn add react-native-picklist

Install by NPM:

npm install --save react-native-picklist

Usage

Import the module in the file:

import PickList from 'react-native-picklist';

export default class TopPage extends React.PureComponent {
    static navigationOptions = PickList.navigationOptions;

    render() {
        return (
            <PickList
                // ...
            />
        );
    }
}

If you want to use button in navigationOptions, you should set following items:

import { HeaderButton } from 'react-navigation-header-buttons';

HeaderButton.defaultProps.getButtonElement = (props) => {
    const {title} = props;
    return (
        <Text>
            {title}
        </Text>
    );
};

You can set the following properties or see example project to learn how to use it.

Properties

Required:

  • title: Page title.
  • data: Data to show. We will construct a virtual root node to contain it.
  • navigation: Navigator's props.

Optional:

  • firstTitleLine: First item displayed in TitleLine when it has the multi-level data and show the title line.
  • isCascade: When multi-level and multi-select are true, auto-cascading selects child nodes or not. Default is true.
  • multilevel: Has multi-level data or not. Default is false.
  • multiselect: Is multi-select or not. Default is false.
  • onFinish: Pass the selected items when finish selecting.
  • rightTitle: Button title on the right corner.
  • rightClick: Button click callback on the right corner.
  • renderRow: Customize a row display. You can override this property to make the list readonly. Default implement is in DefaultRow.js.
  • renderHeader: Customize header of page.
  • renderSingleSelectIcon: Customize single-selected icon.
  • renderMultiSelectIcon: Customize multi-selected icon.
  • showBottomView: Show bottom bar or not.
  • showSearchView: Show search bar or not.
  • showTitleLine: Show title line at the header or not.
  • showAllCell: Show select all or deselect all cell or not.
  • showCount: Show not leaf item's children count and selected count.
  • numberOfTextLines: Max number of lines of Text component in one row. Default is 0, means no restrict of lines. You can set to 1 for single line text mode.
  • directBackWhenSingle: Directly go back to previous page or not when single-select data.
  • cancelableWhenDirectBack: Selected item is cancelable or not when single-select data and directBackWhenSingle is true.
  • selectedIds: Initial selected item's identifier list.
  • selectable: Can a tree node selectable or not.
  • childrenKey: Children key of tree node.
  • idKey: Identifier key of tree node, supports array of string or one string only.
  • labelKey: Label key of tree node.
  • searchKeys: Normal search keys of tree node.
  • sort: Sort method for data list.
  • split: Split method when generate sections of data list.
  • flatListProps: Props of FlatList when data is flat.
  • sectionListProps: Props of SectionList when data is splitted to sections.
  • searchListProps: Props of FlatList when searching.
  • buttonProps: Props of HeaderButton in navigation bar.
  • labels: Label text in component.

You can change labels globally by following statement:

PickList.defaultProps.labels.xxx = 'xxx';

You can call function with PickList view reference:

<PickList
    ref={this.picklist = ref}
    ...
/>

this.picklist.xxx();

Following functions supported:

  • getSelectedItems: () => Tree[]: Get current selected items. You can handle these with Tree API.
  • backToPreviousPage: () => boolean: Auto go back to previous page. If it is the first page, it returns false. Otherwise it returns true.

Example Project

You can open the example project by following steps:

  1. Enter example. Use yarn or npm install to install the modules. Run npm start in a seperate terminal.
  2. Create a example project with entry file index and module name test.

react-native-picklist's People

Contributors

dependabot[bot] avatar hellomjx avatar summer88123 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

react-native-picklist's Issues

Defaults Props Label missing

Hi,
I have a problem for language support. You see attached screenshot. In my code is:

    InnerPickList.defaultProps.labels.close = 'Close';
    InnerPickList.defaultProps.labels.selectAll = 'Select All';
    InnerPickList.defaultProps.labels.deselectAll = 'Deselect All';
    InnerPickList.defaultProps.labels.search = 'Search';
    InnerPickList.defaultProps.labels.ok = 'Ok';
    InnerPickList.defaultProps.labels.choose = Please Select';

but when I entering keyword input. search button title text is Chinese. I am making mistake?

screen shot 2019-01-02 at 11 10 48

React Native > 61 is not working

Hi,
I have a problem with React Native latest version. I don't change code upgraded code.
But I have occurred problem.

Screen Shot 2019-10-09 at 09 51 49

My project version info:
"react": "16.9.0",
"react-native": "0.61.0",

thanks.

[Question] Single select mode

Hello,

I have a question regarding the single select mode. I found that in this mode, it is possible to deselect item. Is it expected behavior? If yes, is it possible to add props to disable this behavior?

If you need sample, ping me.

[Question] Navigation bar

Hi,

Is it possible to also add option to disable rendering navi bar (_renderNaviBar)
Otherwise I need to update it style to be compliant with app style or vs.

Thank you for component!

[Enhancement] Styles modification

Hi,
May I ask you to add props for styles modification?
I'm interested in backgroundColor for picker screen. We can now use custom rows, but it is not possible to modify screen bg.

Thank you beforehand!

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.