1.0.9 • Published 5 years ago

react-native-awesome-list v1.0.9

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

react-native-awesome-list

npm version npm version

React Native animated list with groups and subgroups

npm.io npm.io

Installation

  1. npm install react-native-awesome-list --save or yarn add react-native-awesome-list
  2. react-native link react-native-awesome-list

Usage

import AwesomeList from 'react-native-awesome-list'
...
render() {
    let data = [
      {
        id: Math.random(),
        type: 'group',
        items: [{
          id: Math.random(),
          type: 'subgroup',
          items: [{id: Math.random()}, {id: Math.random()}]
        }, {
          id: Math.random(),
          type: 'subgroup',
          items: [{id: Math.random()}, {id: Math.random()}]
        }]
      },
      {
        id: Math.random(),
        type: 'group',
        items: [{id: Math.random()}, {id: Math.random()}]
      },
      {
        id: Math.random(),
      },
    ]
    return (
      <AwesomeList
        data={data}
        renderItem={this.renderItem}
        renderGroup={this.renderGroup}
        renderSubGroup={this.renderSubGroup}
        renderAnimatingHeader={()=> this.renderAnimatingHeader('HEADER')}
        renderAnimatingFooter={()=> this.renderAnimatingHeader('FOOTER')}
      />
    );
  }

  renderAnimatingHeader(title){
    return (
      <View style={{flex: 1, backgroundColor: 'yellow', justifyContent: 'center', alignItems: 'center'}}>
        <Text>{title}</Text>
      </View>
    );
  }

  renderItem(row){
    return (
      <View style={{backgroundColor: 'red', height: 50, marginVertical: 1}}/>
    );
  }

  renderGroup(){
    return (
      <View style={{backgroundColor: 'blue', height: 50, marginVertical: 1}}/>
    );
  }
  
  renderSubGroup(){
    return (
      <View style={{backgroundColor: 'green', height: 50, marginVertical: 1}}/>
    );
  }
...

Props

PropDefaultTypeDescription
dataundefinedarraydata for list
contentContainerStyleundefinedstyleroot scrollview style
any FlatList propsundefinedpropsyou can provide FlatList props like ItemSeparatorComponent etc.
childListPropsundefinedpropsyou can provide child list props
renderItemundefinedfuncrender function for list item rendering
renderGroupundefinedfuncrender function for list group rendering
renderSubGroupundefinedfuncrender function for list subgroup rendering
toggleGroupfuncfuncreturn index of clicked group and is group expanded bool
toggleSubGroupfuncfuncreturn id of clicked subgroup and is subgroup expanded bool
headerHeight100numberheader height
footerHeight100numberfooter height
renderAnimatingHeaderundefinedfuncrender function for list animated header rendering
renderAnimatingFooterundefinedfuncrender function for list animated footer rendering
disableScaleAnimationfalsebooldisabling scale animation while scroll
disableOpacityAnimationfalsebooldisabling opacity animation while scroll

Enjoy

Questions or suggestions?

Feel free to open an issue