1.0.1 • Published 4 years ago

rn-search-filter v1.0.1

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

RN-Search-Filter

  • npm install rn-search-option-bar --save

Example One

New Features

  • Fork from
  • Fix problem PropTypes
  • Add deactived button style inactivebuttonStyle
  • Add deactived text style inactivetextStyle

How it works

  • The first option shows as selected by default
  • The buttonStyle backgroundColor will be applied to the selected option
  • Unselected options are transparent background
  • Unselected option's text gets the button's backgroundColor as it's color
import React from 'react';

import { StyleSheet } from 'react-native';

const styles = StyleSheet.create({
  searchOptionBar:{
     height: 50,
     backgroundColor: colors.pageBackground,
     borderBottomColor: 'black',
     borderBottomWidth: StyleSheet.hairlineWidth
   },
   searchOptionButton: {
     width: 80,
     height: 30,
     borderRadius: 12,
     borderWidth: StyleSheet.hairlineWidth,
     borderColor: 'blue',
     backgroundColor: 'blue'
   },
   inactivesearchOptionButton:{
     height: 80,
     paddingTop:10,
     paddingLeft:7,
     paddingRight:10,
     paddingBottom:10,
     marginTop: 10,
     backgroundColor: COLORS.secendery,
   },
   buttonText:{
     color:'white',
     fontSize:14
   },
   inactivebuttonText:{
      color:'white',
      fontSize:14
}
 })


import SearchOptionBar from 'rn-search-filter';

class SearchOptionBarExample extends React.Component {
  render(){
    return(
      <SearchOptionBar
        onPress={ (opt) => console.log(opt) }
        options={ ['Electronic','Industrail', 'Instrumental' ,'Techno'] }
        containerStyle={ styles.searchOptionBar }
        buttonStyle={ styles.searchOptionButton }
        textStyle={ styles.buttonText }
        inactivebuttonStyle={ styles.inactivesearchOptionButton }
        inactivetextStyle={ styles.inactivebuttonText }
      />    
    )
  };

}

Props

PropTypeDescriptionRequired
optionsArray of StringsThe options listed in the buttonsYES
onPressfunctionthe function called when the button is pressed, called with the string as the argumentYES
buttonStyleobjectstyles applied to the buttonsYES must include backgroundColor
inactivebuttonStyleobjectstyles applied to the inactive buttonsYES must include backgroundColor
containerStyleobjectstyles applied to the containerYES
textStyleobjectstyles for the text, color will only be applied to the selected optionYES must include color
inactivetextStyleobjectstyles for the text, color will only be applied to the unselected optionYES must include color
showsHorizontalScrollIndicatorbooleanshow the scroll indicatorno