Skip to content

Commit 83a81c6

Browse files
author
Jickson P
committed
map screen
1 parent a03cf8a commit 83a81c6

File tree

4 files changed

+146
-0
lines changed

4 files changed

+146
-0
lines changed

src/routes.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ export default {
1414
},
1515
},
1616

17+
map: {
18+
title: GLOBAL.SCREEN_TITLE.MAP,
19+
component: require('./scenes/MapScreen').default,
20+
},
21+
1722
github: {
1823
title: GLOBAL.SCREEN_TITLE.GITHUB_API,
1924
component: require('./scenes/GithubApis').default,

src/scenes/MapScreen.js

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
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;

src/scenes/Navigation.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,13 @@ export default class Navigation extends Component {
7373
onPress: () => this.changeScene('github'),
7474
onLongPress: () => this.changeScene('github')
7575
},
76+
{
77+
icon: 'map',
78+
value: 'Map',
79+
active: !route || route === 'map',
80+
onPress: () => this.changeScene('map'),
81+
onLongPress: () => this.changeScene('map')
82+
},
7683
// {
7784
// icon: 'home',
7885
// value: 'Logout',

src/utils/Globals.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ module.exports = {
55
QR_CODE_SCANNER: 'QR Code Scanner',
66
SCAN_QR_CODE: 'Scan QR Code',
77
GITHUB_API: 'Github Profile API',
8+
MAP: 'Map',
89
LOGOUT: 'Logout',
910
},
1011
COLOR: {

0 commit comments

Comments
 (0)