Giter Club home page Giter Club logo

react-native-selectable-flatlist's Introduction

react-native-selectable-flatlist

Single/Multi Select Flatlist

Getting started

$ npm install react-native-selectable-flatlist --save

DEMO

Usage

import React, { Component } from 'react';
import { View, Text,StyleSheet } from 'react-native';
import SelectableFlatlist, { STATE } from 'react-native-selectable-flatlist';

class Example extends Component {

  itemsSelected = (selectedItem) => {
    console.log(selectedItem);
  }

  rowItem = (item) => (
    <View
      style={{
        flex: 1,
        borderBottomWidth: 0.5,
        alignItems: 'flex-start',
        justifyContent: 'center',
        paddingVertical: 20,
        borderBottomColor: '##dfdfdf'
      }}
    >
      <Text>{item.test}</Text>
    </View>
  )

render(){
  return(
    <View style={styles.container}>
        <SelectableFlatlist
          data={[{ test: 'test1' }, { test: 'test2' }, { test: 'test3' }]}
          state={STATE.EDIT}
          multiSelect={false}
          itemsSelected={(selectedItem) => { this.itemsSelected(selectedItem); }}
          initialSelectedIndex={[0]}
          cellItemComponent={(item, otherProps) => this.rowItem(item)}
        />
    </View>
  )
}
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    paddingTop: 40
  }
});

export default Example;

Props

name required default description
data yes [] data is just a plain array.
state yes STATE.EDIT STATE.DEFAULT, without selection. STATE.EDIT with selection.
cellItemComponent yes Child row component to render next check/uncheck componenet.
touchStyles no Styles for touch wrapper.
renderCheck no Custom Component to render when a row is checked.
checkUncheckContainerStyle no Container style of check/uncheck default component.
checkColor no #00FF00 Default Color of check icon.
checkUncheckSize no 30 Size(Number) of check/uncheck icon.
checkIcon no Custom check icon.
renderUncheck no Custom Component to render when a row is unchecked.
uncheckColor no #dfdfdf Default Color of uncheck icon.
uncheckIcon no Custom uncheck icon.
initialSelectedIndex yes Array of initially selected item index(Eg:- [0] or [] or [0,1,6]).
itemsSelected yes Callback function when an item checked/unchecked which returns selected items array.
multiSelect yes false Boolean, single/multi select, true refers to multiselect.

react-native-selectable-flatlist's People

Contributors

ashrithks avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  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.