Skip to content

Instantly share code, notes, and snippets.

@Anahkiasen
Created October 19, 2015 08:32
Show Gist options
  • Save Anahkiasen/8222f36bda5aea656715 to your computer and use it in GitHub Desktop.
Save Anahkiasen/8222f36bda5aea656715 to your computer and use it in GitHub Desktop.
import React, {Component, PropTypes, View, TextInput, ActivityIndicatorIOS} from 'react-native';
import {searchStyles} from '../styles';
export default class SearchBar extends Component {
static propTypes = {
isLoading: PropTypes.bool.isRequired,
search: PropTypes.func.isRequired,
};
static defaultProps = {
isLoading: false,
};
/**
* Execute a search
*
* @param {String} query
*/
search(query: string) {
this.props.search(query.toLowerCase());
}
render() {
return (
<View style={searchStyles.searchBar}>
<TextInput
autoCapitalize="none"
autoCorrect={false}
onChangeText={::this.search}
placeholder="Search a repository..."
style={searchStyles.searchBarInput}
/>
{this.props.isLoading && (
<ActivityIndicatorIOS
animating={this.props.isLoading}
style={searchStyles.spinner}
/>
)}
</View>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment