-
Notifications
You must be signed in to change notification settings - Fork 455
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Searchbar at the top of ListView #75
Comments
actually I saw this behaviour on whatsapp app for ios. When user scroll down at the top of the page then the searchbar appear. How do I prepare such component here is my ListView class Products extends React.Component {
constructor (props) {
super(props)
this._renderRow = this._renderRow.bind(this)
this.state = {
dataSource: [],
search: null
}
this.api = API.create()
(this: any).onSearchChange = this.onSearchChange.bind(this)
}
componentDidMount () {
const { id } = this.props
this.api.getList(id).then(result => {
this.setState({
dataSource: result.data.results
})
})
}
_renderRow (datas) {
const cardViews =datas.map((rowData, i) => {
return (
<TouchableOpacity key={rowData.id+':'+i} onPress={() => { console.log('set') }}>
<Image styleName="medium-wide" source={{ uri: rowData.image }}>
<Tile>
<Subtitle styleName="md-gutter-bottom">{rowData.display_name}</Subtitle>
</Tile>
</Image>
</TouchableOpacity>
)
})
return (
<GridRow columns={2}>
{cardViews}
</GridRow>
)
}
onSearchChange (search) {
this.setState({search})
}
_renderProducts(List) {
const groupedList = GridRow.groupByRows(List, 2)
return (
<ListView data={ groupedList } stickyHeaderIndices={[0]} loading={true} renderRow={ this._renderRow } renderHeader={() => <ListViewSearchHeader onSearchChange={this.onSearchChange} search={this.state.search} />} />
)
}
render () {
return (
<Screen style={{ marginTop: Metrics.navBarHeight }}>
{this._renderProducts(this.state.dataSource)}
</Screen>
)
}
} and this is my searchbar const SearchBar = ({search, onSearchChange}) => {
const onChange = (text) => {
onSearchChange(text)
}
return (
<View style={styles.container}>
<TextInput
style={styles.input}
placeholder="Search..."
onChangeText={(text) => onChange(text)}
/>
</View>
)
} now the searchbar will always appear and I still looking ways to filter data on the listview. Please help |
In your case, when you enter search term you need to filter
Notes:
|
thanks for the enlightment. but right now what I need is to hide the searchbar on initial appearance then only appear if user drag down the list. Here the similar issue facebook/react-native#1641 |
@infacq Use autoHideHeader along with renderHeader method. This is how I am doing it:
|
hello guys, i can't figure out how to clear the spinner when it's triggered by an |
Use the this.setState({ isLoading : false }) after fetching the data is complete.
isLoading is the state variable that you specify in the ListView's settings.
On Jan 6, 2017, at 1:58 PM, louis <[email protected]<mailto:[email protected]>> wrote:
hello guys, i can't figure out how to clear the spinner when it's triggered by an onPress function (aka pull to refresh), any idea ?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub<#75 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AGZF_tv0knYVpCINihqgCD1Jac0vtG_gks5rPrkLgaJpZM4KiCyT>.
|
How do I make a search bar when the page scroll to the top only. Thank you
The text was updated successfully, but these errors were encountered: