/src/screens/StoriesScreen/StoriesList.js

https://github.com/kiok46/duckduckgo · JavaScript · 63 lines · 50 code · 11 blank · 2 comment · 0 complexity · 58c2e9811b2b2991dae3d5b16e791503 MD5 · raw file

  1. import React, { Component } from 'react';
  2. import { Text, TextInput, Dimensions, View, ScrollView, StyleSheet } from 'react-native';
  3. import StoriesDetail from './StoriesDetail';
  4. import axios from 'axios';
  5. import Colors from '../../constants/Colors';
  6. import storyData from '../../constants/data';
  7. class StoriesList extends Component {
  8. constructor(props) {
  9. super(props);
  10. }
  11. componentWillMount(){
  12. //axios.get("http://api.duckduckgo.com/?q=googl&format=json")
  13. // .then(response => this.setState({ stories: response.data}));
  14. }
  15. getStoryData(story) {
  16. return (
  17. <StoriesDetail key={story.title}
  18. StoryImage={story.urlToImage}
  19. StoryAbstractURL={story.url}
  20. StoryHeading={story.title}
  21. />
  22. );
  23. }
  24. renderStories() {
  25. return (storyData.map(this.getStoryData));
  26. }
  27. render () {
  28. return (
  29. <ScrollView>
  30. {this.renderStories()}
  31. </ScrollView>
  32. );
  33. }
  34. }
  35. const styles = StyleSheet.create({
  36. viewStyle: {
  37. backgroundColor: '#eeeeee',
  38. justifyContent: 'center',
  39. alignItems: 'center',
  40. height: 60,
  41. paddingTop: 15,
  42. shadowColor: '#000',
  43. shadowOffset: { width: 0, height: 2 },
  44. shadowOpacity: 0.2,
  45. elevation: 2,
  46. position: 'relative'
  47. },
  48. textStyle: {
  49. fontSize: 20
  50. }
  51. });
  52. export default StoriesList;