0.2.1 • Published 4 years ago

react-native-flatlist-selector v0.2.1

Weekly downloads
9
License
ISC
Repository
github
Last release
4 years ago

NPM version npm Package Quality Compatibility

NPM

If this project has helped you out, please support us with a star 🌟

📘 Description

Author: Kite

Github: https://github.com/KiteOfficial/react-native-flatlist-selector

A Selectable Flatlist which you can Highlight a selected item

_Tested with: Android, iOS

This project is so many more to improve, please raise an suggestions in ISSUES. It will great help not for me but for react-native developer.

📖 Install

Install the library from npm just running one of the following command lines:

npm
npm install react-native-flatlist-selector --save

💻 Usage

import { Selector } from "react-native-flatlist-selector";

// Example
class Main extends Component {
  constructor(props) {
    super(props)
    this.data = [{
      title: 'REGION 1',
      image: require('images/region1.png'),
    },
    {
      title: 'REGION 2',
      image: require('images/region2.png'),
    },
    {
      title: 'REGION 3',
      image: require('images/region3.png'),
    }]
  }

  state = {
    selectedIndex: 0
  }

  getIndex = (selectedIndex) => {
    this.setState({ selectedIndex: selectedIndex })
  }
  render() {
    return (
      <SafeAreaView style={styles.container}>
        <Text>Selected Index: {this.state.selectedIndex} </Text>
        <Selector
          multiple={true}
          selectedIndex={this.getIndex}
          data={this.data}
          renderItem={(item, index) => (
            <>
              <Text>Asa</Text>
              <Text>{index.image}</Text>
              <Text>{index}</Text>
              <Text>{item.title}</Text>
            </>
          )} />
      </SafeAreaView>
    )
  }
}

🎥 DEMO

Single SelectionMultiple Selection

Props

PropertyDescriptionTypeDefault.Note
multipleEither multiple selection or singleBooleanfalse
dataArray of data to be render.ArrayOnly 2D array is acceptable
selectedColorHiglight for selected ItemString#3535356E
unselectedColorHiglight for unselected ItemStringtransparent
selectedIndexDefault selected itemInt, ArrayInt for single, Array for multiple
getSelectedIndexGet selected index.Function
renderItemComponent to be renderedFunction.
Flatlist PropsAll Flatlist Props are accepted

🤔 How to contribute

Having any suggestions on your mind? Found a bug? Don't shy to share in ISSUES. Contributions are welcome and are greatly appreciated! Every little bit helps, and credit will always be given.

0.2.1

4 years ago

0.2.0

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago