1.0.4 • Published 7 years ago

react-native-category v1.0.4

Weekly downloads
8
License
ISC
Repository
github
Last release
7 years ago

react-native-category npm version

NPM

  • A React Native component for generating and displaying interactive category list.
  • Compatible with both Android and iOS.

  • Detailed Example

Installation

npm i --save react-native-category

And then set up react-native-vector-icons for your project.

Please file an issue if you have any trouble!

Usage

import Category from 'react-native-category';

....

constructor(props) {
  super(props);

  //setup data category
  this.data = [
    {id: 1, title: 'Apple'},
    {id: 2, title: 'Samsung'},
    {id: 3, title: 'Sony'},
    {id: 4, title: 'Nokia'},
    {id: 5, title: 'HTC'},
    {id: 6, title: 'LG'}
  ];
}

//func call when click item category
_itemChoose(item) {
  alert(item.title);
}

.....
//in render

<Category
  data={this.data}    
  itemSelected={(item) => this._itemChoose(item)}
  itemText={'title'}  //set attribule of object show in item category
/>

Props

Category type Text Item

PropTypeDescriptionRequiredDefault
dataarrayData categoryYes[]
itemTextstringAttribule show in item categoryYes''
itemSelectedfunctionA function to handle item category presses.YesNone
textTypestringSet type for text (upper, lower, capitalize)NoNone
indexSelectednumberSet item category selected defaultNo0

Category type Image Item

PropTypeDescriptionRequiredDefault
imageDataarrayImage data categoryNo[]
iconSetstringThe name of the icon set item category image belongs to. Refer to react-native-vector-icons.NoFontAwesome
iconSizenumberSet size icon item categoryNo30

Category props style

PropTypeDescriptionRequiredDefault
stylestyleCustom style for categoryNoNone
itemStylesstyleCustom style for item categoryNoNone
colorTextDefaultstringSet Color text defaultNo#f5f3f4
colorTextSelectedstringSet Color text selectedNo#000000
colorItemDefaultstringSet Color item defaultNorgba(255,255,255,0.2)
colorItemSelectedstringSet Color item selectedNo#FF4E50
colorIconDefaultstringSet Color icon defaultNo#900
colorIconSelectedstringSet Color icon selectedNo#FFF
bouncesboolBounces iOSNofalse

License

ISC