Skip to content

Instantly share code, notes, and snippets.

View edipofederle's full-sized avatar
🏠
Working from home

Édipo Féderle edipofederle

🏠
Working from home
View GitHub Profile
<Text style={styles.description}>{this.state.message}</Text>
quote:{
fontSize: 9,
justifyContent: 'center'
}
<Text style={styles.quote}>{this.state.quote}</Text>
_handleResponse(response) {
this.setState({quote: response.quote });
}
function buildApiUrl(query) {
var query = query.split(' ').join('_').toLowerCase() + "+";
return "http://www.iheartquotes.com/api/v1/random?format=json&source="+query
};
onSearchPressed() {
fetch(buildApiUrl(this.state.query))
.then(response => response.json())
.then(json => this._handleResponse(json))
.catch(error =>
this.setState({
message: 'Shit!' + error,
isLoading: false}));
}
<TouchableHighlight style={styles.button} underlayColor='#99d9f4'>
<Text style={styles.buttonText}
onPress={this.onSearchPressed.bind(this)}>GO</Text>
<View style={styles.flowRight}>
<TextInput style={styles.queryInput}
onChange = {this.onQueryTextChanged.bind(this)}
value = {this.state.query}/>
onQueryTextChanged(textInput) {
this.setState({query: textInput.nativeEvent.text});
console.log("---> " + this.state.query);
}
button: {
height: 36,
flex: 1,
flexDirection: 'row',
backgroundColor: '#48BBEC',
borderColor: '#48BBEC',
borderWidth: 1,
borderRadius: 8,
marginBottom: 10,
alignSelf: 'stretch',