|
| 1 | +import React from 'react'; |
| 2 | + |
| 3 | +import { |
| 4 | + Component, |
| 5 | + View, |
| 6 | + Text, |
| 7 | + ProgressBarAndroid as ProgressBar, |
| 8 | + StyleSheet, |
| 9 | +} from 'react-native'; |
| 10 | + |
| 11 | +import { |
| 12 | + Card, |
| 13 | +} from 'react-native-material-design'; |
| 14 | + |
| 15 | +import * as GLOBAL from '../utils/Globals'; |
| 16 | +import NetworkImageView from '../components/NetworkImageView'; |
| 17 | + |
| 18 | +const styles = StyleSheet.create({ |
| 19 | + container: { |
| 20 | + backgroundColor: GLOBAL.COLOR.BACKGROUND, |
| 21 | + flex: 1, |
| 22 | + justifyContent: 'center', |
| 23 | + alignItems: 'center', |
| 24 | + paddingTop: 16, |
| 25 | + }, |
| 26 | + card_container: { |
| 27 | + padding: 16, |
| 28 | + justifyContent: 'center', |
| 29 | + alignItems: 'center', |
| 30 | + }, |
| 31 | + loading: { |
| 32 | + justifyContent: 'center', |
| 33 | + }, |
| 34 | + profile: { |
| 35 | + width: 200, |
| 36 | + height: 200, |
| 37 | + marginBottom: 8, |
| 38 | + }, |
| 39 | + name: { |
| 40 | + fontSize: 20, |
| 41 | + fontWeight: '500', |
| 42 | + color: GLOBAL.COLOR.PRIMARY_TEXT, |
| 43 | + }, |
| 44 | + handle: { |
| 45 | + fontSize: 14, |
| 46 | + fontWeight: '300', |
| 47 | + color: GLOBAL.COLOR.SECONDARY_TEXT, |
| 48 | + }, |
| 49 | + email: { |
| 50 | + fontSize: 16, |
| 51 | + fontWeight: '400', |
| 52 | + color: GLOBAL.COLOR.PRIMARY_TEXT, |
| 53 | + }, |
| 54 | + follower_container: { |
| 55 | + flexDirection: 'row', |
| 56 | + marginTop: 16, |
| 57 | + } |
| 58 | +}); |
| 59 | + |
| 60 | +class MapScreen extends Component { |
| 61 | + |
| 62 | + constructor(props, context) { |
| 63 | + super(props, context); |
| 64 | + this.github_username = 'mojombo'; |
| 65 | + this.github_url = 'https://api.github.com/users/'; |
| 66 | + |
| 67 | + this.state = { |
| 68 | + user: null, |
| 69 | + isLoaded: null, |
| 70 | + }; |
| 71 | + } |
| 72 | + |
| 73 | + |
| 74 | + componentDidMount() { |
| 75 | + // TODO Move this to container later |
| 76 | + //this.fetchUserData(); |
| 77 | + } |
| 78 | + |
| 79 | + fetchUserData() { |
| 80 | + const REQUEST_URL = this.github_url + this.github_username; |
| 81 | + global.LOG('REQUEST_URL',REQUEST_URL); |
| 82 | + |
| 83 | + // TODO do error handling |
| 84 | + fetch(REQUEST_URL) |
| 85 | + .then((response) => response.json()) |
| 86 | + .then((responseData) => { |
| 87 | + this.setState({ |
| 88 | + user: responseData, |
| 89 | + isLoaded: true, |
| 90 | + }) |
| 91 | + }) |
| 92 | + .done(); |
| 93 | + } |
| 94 | + // { |
| 95 | + // "login": "jicksonp", |
| 96 | + // "id": 16488048, |
| 97 | + // "avatar_url": "https://avatars.githubusercontent.com/u/16488048?v=3", |
| 98 | + // "gravatar_id": "", |
| 99 | + // "url": "https://api.github.com/users/jicksonp", |
| 100 | + // "html_url": "https://github.com/jicksonp", |
| 101 | + // "followers_url": "https://api.github.com/users/jicksonp/followers", |
| 102 | + // "following_url": "https://api.github.com/users/jicksonp/following{/other_user}", |
| 103 | + // "gists_url": "https://api.github.com/users/jicksonp/gists{/gist_id}", |
| 104 | + // "starred_url": "https://api.github.com/users/jicksonp/starred{/owner}{/repo}", |
| 105 | + // "subscriptions_url": "https://api.github.com/users/jicksonp/subscriptions", |
| 106 | + // "organizations_url": "https://api.github.com/users/jicksonp/orgs", |
| 107 | + // "repos_url": "https://api.github.com/users/jicksonp/repos", |
| 108 | + // "events_url": "https://api.github.com/users/jicksonp/events{/privacy}", |
| 109 | + // "received_events_url": "https://api.github.com/users/jicksonp/received_events", |
| 110 | + // "type": "User", |
| 111 | + // "site_admin": false, |
| 112 | + // "name": "Jickson P", |
| 113 | + // "company": "Peppertap", |
| 114 | + // "blog": null, |
| 115 | + // "location": "Gurgaon,India", |
| 116 | + // "email": "jicksonstephen@gmail.com", |
| 117 | + // "hireable": null, |
| 118 | + // "bio": null, |
| 119 | + // "public_repos": 4, |
| 120 | + // "public_gists": 0, |
| 121 | + // "followers": 1, |
| 122 | + // "following": 6, |
| 123 | + // "created_at": "2015-12-30T10:45:35Z", |
| 124 | + // "updated_at": "2016-05-05T09:31:27Z" |
| 125 | + // } |
| 126 | + render() { |
| 127 | + return ( |
| 128 | + <View><Text>Hello world</Text></View> |
| 129 | + ) |
| 130 | + } |
| 131 | +} |
| 132 | + |
| 133 | +export default MapScreen; |
0 commit comments