Skip to content

Commit 9a66a74

Browse files
author
Simar Singh
committed
finished the first screen, added readme.md with a screenshot
1 parent c6456e9 commit 9a66a74

File tree

8 files changed

+53
-7
lines changed

8 files changed

+53
-7
lines changed

Diff for: App/Views/Post/index.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
'use strict';
2+
3+
var React = require('react-native');
4+
5+
var {
6+
View,
7+
Text,
8+
} = React;
9+
10+
var styles = require('./style');
11+
12+
var Post = React.createClass({
13+
render: function() {
14+
return (
15+
<View>
16+
<Text>Hello World!</Text>
17+
</View>
18+
);
19+
}
20+
});
21+
22+
module.exports = Post;

Diff for: App/Views/Post/style.js

Whitespace-only changes.

Diff for: App/Views/Posts/Elements/PostCell/index.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,25 @@ var React = require('react-native');
44

55
var {
66
Text,
7-
View
7+
View,
8+
TouchableHighlight
89
} = React;
910

1011
var styles = require("./style");
1112

1213
var PostCell = React.createClass({
1314
render: function() {
1415
return (
16+
<TouchableHighlight onPress={this.props.onSelect}>
1517
<View style={styles.container}>
1618
<Text style={styles.postCount}>
1719
{this.props.post.count}
1820
</Text>
19-
<Text style={styles.postTitle}>
20-
{this.props.post.title.text}
21-
</Text>
21+
<Text style={styles.postTitle}>
22+
{this.props.post.title.text}
23+
</Text>
2224
</View>
25+
</TouchableHighlight>
2326
);
2427
}
2528
});

Diff for: App/Views/Posts/Elements/PostCell/style.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ module.exports = StyleSheet.create({
2828
marginTop: 10,
2929
marginBottom: 10,
3030
marginRight: 10,
31-
color: '#000000'
31+
color: '#FF6600'
3232
},
3333
});

Diff for: App/Views/Posts/index.js

+13-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
var React = require('react-native');
44

55
var {
6-
AppRegistry,
76
Text,
87
View,
98
ListView,
@@ -15,6 +14,9 @@ var api = require("../../Network/api.js");
1514
//View Elements
1615
var PostCell = require("./Elements/PostCell");
1716

17+
//Views
18+
var PostView = require("../Post");
19+
1820
var ViewReactClass = React.createClass({
1921
getInitialState: function() {
2022
return {
@@ -60,9 +62,18 @@ var ViewReactClass = React.createClass({
6062
},
6163
renderPostCell: function(post){
6264
return(
63-
<PostCell post={post}/>
65+
<PostCell
66+
onSelect={() => this.selectPost(post)}
67+
post={post}/>
6468
);
6569
},
70+
selectPost: function(post){
71+
this.props.navigator.push({
72+
title: "Top Story #"+post.count.substring(0, post.count.length - 1),
73+
component: PostView,
74+
passProps: {},
75+
});
76+
},
6677

6778
});
6879

Diff for: README.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# HackerNews-React-Native
2+
3+
Made with React-Native.
4+
5+
## Screenshot:
6+
<center>
7+
<img src="http://i.imgur.com/vfvL9Mj.png" height="700" width="250"/>
8+
</center>

Diff for: index.ios.js

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ var HackerNews = React.createClass({
1515
return (
1616
<NavigatorIOS
1717
style={styles.container}
18+
tintColor='#FF6600'
1819
initialRoute={{
1920
title: 'Hacker News - Top Stories',
2021
component: PostsView,
@@ -26,6 +27,7 @@ var HackerNews = React.createClass({
2627
var styles = StyleSheet.create({
2728
container: {
2829
flex: 1,
30+
backgroundColor: '#F6F6EF',
2931
},
3032
});
3133

0 commit comments

Comments
 (0)