This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Text style={styles.description}>{this.state.message}</Text> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
quote:{ | |
fontSize: 9, | |
justifyContent: 'center' | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Text style={styles.quote}>{this.state.quote}</Text> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_handleResponse(response) { | |
this.setState({quote: response.quote }); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function buildApiUrl(query) { | |
var query = query.split(' ').join('_').toLowerCase() + "+"; | |
return "http://www.iheartquotes.com/api/v1/random?format=json&source="+query | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
onSearchPressed() { | |
fetch(buildApiUrl(this.state.query)) | |
.then(response => response.json()) | |
.then(json => this._handleResponse(json)) | |
.catch(error => | |
this.setState({ | |
message: 'Shit!' + error, | |
isLoading: false})); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<TouchableHighlight style={styles.button} underlayColor='#99d9f4'> | |
<Text style={styles.buttonText} | |
onPress={this.onSearchPressed.bind(this)}>GO</Text> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<View style={styles.flowRight}> | |
<TextInput style={styles.queryInput} | |
onChange = {this.onQueryTextChanged.bind(this)} | |
value = {this.state.query}/> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
onQueryTextChanged(textInput) { | |
this.setState({query: textInput.nativeEvent.text}); | |
console.log("---> " + this.state.query); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
button: { | |
height: 36, | |
flex: 1, | |
flexDirection: 'row', | |
backgroundColor: '#48BBEC', | |
borderColor: '#48BBEC', | |
borderWidth: 1, | |
borderRadius: 8, | |
marginBottom: 10, | |
alignSelf: 'stretch', |