react-native-complete-flatlist
Advanced tools
Comparing version 1.1.16 to 1.1.17
86
index.js
@@ -1,3 +0,3 @@ | ||
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 { | ||
@@ -10,11 +10,11 @@ StyleSheet, | ||
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: "" | ||
}; | ||
@@ -38,3 +38,3 @@ | ||
if (this.props.data.length === 0) { | ||
filtereddata = [{ type: 'emptyrow', name: 'No data available' }]; | ||
filtereddata = [{ type: "emptyrow", name: "No data available" }]; | ||
} | ||
@@ -47,3 +47,3 @@ filtereddata = this.props.data; | ||
const { data, searchKey, highlightColor } = this.props; | ||
if (this.state.searchText === '') { | ||
if (this.state.searchText === "") { | ||
return data; | ||
@@ -58,7 +58,7 @@ } | ||
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); | ||
@@ -71,3 +71,3 @@ break; | ||
const key = keys[i]; | ||
if (typeof dt[key] === 'string') { | ||
if (typeof dt[key] === "string") { | ||
row[key] = ( | ||
@@ -96,3 +96,3 @@ <Highlighter | ||
backgroundStyles, | ||
searchBarBackgroundStyles, | ||
searchBarBackgroundStyles | ||
} = this.props; | ||
@@ -121,9 +121,2 @@ const filteredData = this.filterText(); | ||
const refreshcontrol = pullToRefreshCallback !== null && ( | ||
<RefreshControl | ||
refreshing={this.props.isRefreshing} | ||
onRefresh={this.props.pullToRefreshCallback} | ||
/> | ||
); | ||
return ( | ||
@@ -137,10 +130,17 @@ <KeyboardAvoidingView | ||
<FlatList | ||
refreshControl={refreshcontrol} | ||
refreshControl={ | ||
pullToRefreshCallback !== null ? ( | ||
<RefreshControl | ||
refreshing={this.props.isRefreshing} | ||
onRefresh={this.props.pullToRefreshCallback} | ||
/> | ||
) : 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) | ||
} | ||
@@ -167,7 +167,7 @@ style={styles.flatList} | ||
placeholder: PropTypes.string, | ||
elementBetweenSearchAndList: PropTypes.element, | ||
elementBetweenSearchAndList: PropTypes.element | ||
}; | ||
CompleteFlatList.defaultProps = { | ||
searchKey: [], | ||
placeholder: 'Search ...', | ||
placeholder: "Search ...", | ||
data: [], | ||
@@ -178,7 +178,7 @@ isRefreshing: false, | ||
pullToRefreshCallback: null, | ||
highlightColor: '', | ||
highlightColor: "", | ||
backgroundStyles: {}, | ||
searchBarBackgroundStyles: {}, | ||
renderEmptyRow: () => ( | ||
<Text style={styles.noData}>{'No data available'}</Text> | ||
<Text style={styles.noData}>{"No data available"}</Text> | ||
), | ||
@@ -189,32 +189,32 @@ 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; |
{ | ||
"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", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11904
198