3.0.1 • Published 3 years ago

react-native-search-list v3.0.1

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

React Native Search List

A searchable ListView which supports Chinese PinYin and alphabetical index.

A fork of https://github.com/unpourtous/react-native-search-list

The original library was missing some commonly used features that are now implemented and the deprecated ListView was replaced with a SectionList to be compatible with future releases of React Native.

The following picture may be helpful to understand the structure and APIs:

Installation

yarn add react-native-search-list

Usage

To Use SearchList, you will need an array of objects as the data source, and each object has to have a cursor property, example code is in ./example.js.

APIs

prop nametypedescriptiondefault value
dataarrayThe data object
searchCursorstringSet the key in the data array that's being used as the search sourcecursor
renderRownumberRender your custom row content
rowHeightnumberThe height of the default row content, it will be used for scroll calculate40
sectionHeaderHeightnumberThe height of section header content24
listContainerStyleobjectStyle properties for the internal TextInput Component
searchListBackgroundColorstringBackgroundColor for searchList#171a23
toolbarBackgroundColorstringToolbar background color#171a23
searchBarToggleDurationnumberCustom search bar animation duration300
searchBarBackgroundColorstringCustom search bar background color#171a23
searchBarContainerStyleobjectStyle properties for the SearchBar Container Component
searchBarStyleobjectStyle properties for the SearchBar Component
searchOnDefaultValueboolEnable filtered results based on default value
searchIconColorstringCustom color for the search icon#171a23
searchInputBackgroundColorstringCustom search input default state background color#ffffff
searchInputBackgroundColorActivestringCustom search input searching state background color
searchInputPlaceholderstringCustom search input placeholder text
searchInputDefaultValuestringCustom search input default value text
searchInputPlaceholderColorstringCustom search input placeholder text color#979797
searchInputTextColorstringCustom search input default state text color#171a23
searchInputTextColorActivestringCustom search input searching state text color#ffffff
searchInputStyleobjectStyle properties for the internal TextInput Component
toolbarHeightnumberThe height of the tool bar44
searchBarBackgroundColorstringCustom search bar background color
staticCancelButtonboolEnable/Disable a static cancel button with no slide in animationfalse
showSearchIconboolShow/Hide the search icontrue
displayMaskboolShow/Hide the mask during searchingtrue
titlestringToolbar title
titleTextColorstringToolbar title text color
cancelTitlestringSearch bar cancel text colorCancel
cancelTextColorstringSearch bar cancel text color#ffffff
cancelContainerStyleobjectStyle properties for the cancel button container
hideSectionListboolWhether to hide the alphabetical section listing view or not.
sortFuncfuncThe sort function for the list view data source,sorting alphabetical by default
resultSortFuncfuncThe sort function for the search result,sorting first match position by default
onScrollToSectionfuncThe callback of alphabetical section view be clicked or touch
sectionIndexTextColorstringSection index text color
sectionIndexContainerStyleobjectStyle properties for the Section Index Container Component
renderSectionIndexItemfuncCustom render SectionIndexItem.
renderBackButtonfuncRender a custom back buttom on Toolbar.
renderEmptyfuncRender a view when data is empty.
renderEmptyResultfuncRender a view when search result is empty.
renderItemSeparatorfuncRender row separator.
renderSectionHeaderfuncrenderSectionHeader for the internal ListView
renderHeaderfuncrenderHeader for the internal ListView
renderFooterfuncrenderFooter for the internal ListView
renderStickyHeaderfuncrenderStickyHeader for the section below the SearchBar
renderRowfuncrenderRow for the internal ListView
renderToolbarfuncrenderToolbar for the Toolbar
renderCancelfuncrenderCancel for custom rendering of the cancel button
renderCancelWhileSearchingfuncrenderCancelWhileSearching for custom rendering of the cancel button during search
onSearchStartfuncCallback when searching start.
onSearchEndfuncCallback when searching end.

Contributions