From 36383c16461f93adc681b4763173ebbe66bfe503 Mon Sep 17 00:00:00 2001 From: fattahmuhyiddeen Date: Sat, 1 Sep 2018 11:47:41 +0800 Subject: [PATCH] bug fix --- index.js | 86 ++++++++++++++++++++++++++-------------------------- package.json | 2 +- 2 files changed, 44 insertions(+), 44 deletions(-) diff --git a/index.js b/index.js index 73fc2f0..70454c1 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,5 @@ -import React, { Component } from 'react'; -import Highlighter from 'react-native-highlight-words'; +import React, { Component } from "react"; +import Highlighter from "react-native-highlight-words"; import { StyleSheet, Text, @@ -7,15 +7,15 @@ import { FlatList, TextInput, RefreshControl, - KeyboardAvoidingView, -} from 'react-native'; -import PropTypes from 'prop-types'; + KeyboardAvoidingView +} from "react-native"; +import PropTypes from "prop-types"; class CompleteFlatList extends Component { state = { - behavior: 'padding', + behavior: "padding", refreshing: false, - searchText: '', + searchText: "" }; componentDidMount() { @@ -34,7 +34,7 @@ class CompleteFlatList extends Component { refresh = () => { if (this.props.data.length === 0) { - filtereddata = [{ type: 'emptyrow', name: 'No data available' }]; + filtereddata = [{ type: "emptyrow", name: "No data available" }]; } filtereddata = this.props.data; this.setState({ refreshing: false, data: filtereddata }); @@ -42,7 +42,7 @@ class CompleteFlatList extends Component { filterText = () => { const { data, searchKey, highlightColor } = this.props; - if (this.state.searchText === '') { + if (this.state.searchText === "") { return data; } const searchText = this.state.searchText.toLowerCase(); @@ -52,11 +52,11 @@ class CompleteFlatList extends Component { for (let s = 0; s < searchKey.length; s += 1) { sk = searchKey[s]; const target = dt[sk]; - if (typeof target === 'undefined' || target == null) { + if (typeof target === "undefined" || target == null) { continue; } if (target.toLowerCase().indexOf(searchText) !== -1) { - if (highlightColor === '') { + if (highlightColor === "") { filteredData.push(dt); break; } @@ -64,7 +64,7 @@ class CompleteFlatList extends Component { const keys = Object.keys(dt); for (let i = 0; i < keys.length; i += 1) { const key = keys[i]; - if (typeof dt[key] === 'string') { + if (typeof dt[key] === "string") { row[key] = ( ); - const refreshcontrol = pullToRefreshCallback !== null && ( - - ); - return ( 0 && searchbar} {this.props.elementBetweenSearchAndList} + ) : null + } data={filteredData} renderItem={item => - (filteredData.length === 1 && - filteredData[0].showEmptyRow !== null && - typeof filteredData[0].showEmptyRow !== 'undefined' + filteredData.length === 1 && + filteredData[0].showEmptyRow !== null && + typeof filteredData[0].showEmptyRow !== "undefined" ? this.props.renderEmptyRow() - : renderItem(item.item)) + : renderItem(item.item) } style={styles.flatList} ItemSeparatorComponent={renderSeparator} @@ -156,54 +156,54 @@ CompleteFlatList.propTypes = { searchBarBackgroundStyles: PropTypes.object, renderEmptyRow: PropTypes.func, placeholder: PropTypes.string, - elementBetweenSearchAndList: PropTypes.element, + elementBetweenSearchAndList: PropTypes.element }; CompleteFlatList.defaultProps = { searchKey: [], - placeholder: 'Search ...', + placeholder: "Search ...", data: [], isRefreshing: false, renderItem: null, renderSeparator: () => , pullToRefreshCallback: null, - highlightColor: '', + highlightColor: "", backgroundStyles: {}, searchBarBackgroundStyles: {}, renderEmptyRow: () => ( - {'No data available'} + {"No data available"} ), elementBetweenSearchAndList: null }; const styles = StyleSheet.create({ - noData: { alignSelf: 'center', textAlign: 'center', marginTop: 20 }, + noData: { alignSelf: "center", textAlign: "center", marginTop: 20 }, searchBarContainer: { - justifyContent: 'center', + justifyContent: "center", padding: 10, - backgroundColor: '#f2f2f2', - width: '100%', + backgroundColor: "#f2f2f2", + width: "100%" }, searchBar: { borderRadius: 5, - backgroundColor: 'white', + backgroundColor: "white", height: 38, fontSize: 15, - width: '100%', - paddingHorizontal: 10, + width: "100%", + paddingHorizontal: 10 }, container: { flex: 1, - justifyContent: 'center', - alignItems: 'center', - backgroundColor: 'white', + justifyContent: "center", + alignItems: "center", + backgroundColor: "white" }, defaultSeparator: { height: 1, - width: '80%', - alignSelf: 'center', - backgroundColor: '#f2f2f2', + width: "80%", + alignSelf: "center", + backgroundColor: "#f2f2f2" }, - flatList: { height: '100%', width: '100%', backgroundColor: 'transparent' }, + flatList: { height: "100%", width: "100%", backgroundColor: "transparent" } }); export default CompleteFlatList; diff --git a/package.json b/package.json index b29d1b6..9d660d9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-complete-flatlist", - "version": "1.1.16", + "version": "1.1.17", "description": "A complete flatlist with search bar, highlighted search, pull to refresh, and etc is ready to use", "main": "index.js", "scripts": {