Skip to content

Commit 4887235

Browse files
author
soliury
committed
add Topic page
1 parent 233288f commit 4887235

14 files changed

Lines changed: 551 additions & 73 deletions

File tree

ios/noder/AppDelegate.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
3131
* on the same Wi-Fi network.
3232
*/
3333

34-
jsCodeLocation = [NSURL URLWithString:@"http://172.28.162.87:8081/index.ios.bundle?platform=ios&dev=true"];
34+
jsCodeLocation = [NSURL URLWithString:@"http://192.168.31.142:8081/index.ios.bundle?platform=ios&dev=true"];
3535

3636
/**
3737
* OPTION 2

package.json

Lines changed: 45 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,47 @@
11
{
2-
"name": "noder",
3-
"version": "1.0.0",
4-
"scripts": {
5-
"start": "react-native start",
6-
"clean:babelrc": "find ./node_modules -name react-packager -prune -o -name '.babelrc' -print | xargs rm -f",
7-
"postinstall": "npm run clean:babelrc",
8-
"an": "react-native run-android",
9-
"log": "adb logcat *:S ReactNative:V ReactNativeJS:V",
10-
"build-ios": "react-native unbundle --entry-file index.ios.js --platform ios --dev false"
11-
},
12-
"dependencies": {
13-
"lodash": "^4.4.0",
14-
"markdown": "0.5.0",
15-
"moment": "^2.11.2",
16-
"query-string": "^3.0.0",
17-
"react-native": "^0.20.0",
18-
"react-native-barcodescanner": "^1.0.1",
19-
"react-native-blur": "^0.7.10",
20-
"react-native-button": "^1.4.2",
21-
"react-native-camera": "git+https://github.com/lwansbrough/react-native-camera.git",
22-
"react-native-scrollable-tab-view": "^0.3.6",
23-
"react-native-vector-icons": "^1.2.0",
24-
"react-native-vibration": "^0.2.0",
25-
"react-redux": "^4.4.0",
26-
"rebound": "0.0.13",
27-
"redux": "^3.3.1",
28-
"redux-actions": "^0.9.1",
29-
"redux-logger": "^2.5.2",
30-
"redux-promise": "^0.5.1",
31-
"redux-thunk": "^1.0.3"
32-
},
33-
"devDependencies": {
34-
"coffee-script": "^1.9.2",
35-
"dev-ip": "^1.0.1",
36-
"eslint": "^1.1.0",
37-
"eslint-plugin-react": "^3.16.1",
38-
"gulp": "^3.9.1",
39-
"gulp-replace": "^0.5.4",
40-
"gulp-util": "^3.0.4",
41-
"react-native-cli": "^0.1.10",
42-
"redux-devtools": "^3.1.1",
43-
"run-sequence": "^1.1.0"
44-
},
45-
"bundleId": "org.reactjs.native.example.noder"
2+
"name": "noder",
3+
"version": "1.0.0",
4+
"scripts": {
5+
"start": "react-native start",
6+
"clean:babelrc": "find ./node_modules -name react-packager -prune -o -name '.babelrc' -print | xargs rm -f",
7+
"postinstall": "npm run clean:babelrc",
8+
"an": "react-native run-android",
9+
"log": "adb logcat *:S ReactNative:V ReactNativeJS:V",
10+
"build-ios": "react-native unbundle --entry-file index.ios.js --platform ios --dev false"
11+
},
12+
"dependencies": {
13+
"lodash": "^4.4.0",
14+
"markdown": "0.5.0",
15+
"moment": "^2.11.2",
16+
"query-string": "^3.0.0",
17+
"react-native": "^0.20.0",
18+
"react-native-barcodescanner": "^1.0.1",
19+
"react-native-blur": "^0.7.10",
20+
"react-native-button": "^1.4.2",
21+
"react-native-camera": "git+https://github.com/lwansbrough/react-native-camera.git",
22+
"react-native-html-render": "^1.0.3",
23+
"react-native-scrollable-tab-view": "^0.3.6",
24+
"react-native-vector-icons": "^1.2.0",
25+
"react-native-vibration": "^0.2.0",
26+
"react-redux": "^4.4.0",
27+
"rebound": "0.0.13",
28+
"redux": "^3.3.1",
29+
"redux-actions": "^0.9.1",
30+
"redux-logger": "^2.5.2",
31+
"redux-promise": "^0.5.1",
32+
"redux-thunk": "^1.0.3"
33+
},
34+
"devDependencies": {
35+
"coffee-script": "^1.9.2",
36+
"dev-ip": "^1.0.1",
37+
"eslint": "^1.1.0",
38+
"eslint-plugin-react": "^3.16.1",
39+
"gulp": "^3.9.1",
40+
"gulp-replace": "^0.5.4",
41+
"gulp-util": "^3.0.4",
42+
"react-native-cli": "^0.1.10",
43+
"redux-devtools": "^3.1.1",
44+
"run-sequence": "^1.1.0"
45+
},
46+
"bundleId": "org.reactjs.native.example.noder"
4647
}

src/actions/topic.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ import * as types from '../constants/ActionTypes';
33
import * as topicService from '../services/topicService';
44

55

6-
export const getAllTopicsFromStorage = createAction(types.GET_TOPICS_FROM_STORAGE, async ()=> {
7-
return await topicService.storage.getAllTopics();
8-
});
6+
export const getAllTopicsFromStorage = createAction(types.GET_TOPICS_FROM_STORAGE, topicService.storage.getAllTopics);
97

108

119
export const getTopicsByTab = createAction(types.GET_TOPICS_BY_TAB, async (tab, params)=> {
@@ -22,3 +20,17 @@ export const updateTopicsByTab = createAction(types.UPDATE_TOPICS_BY_TAB, async
2220
page: 1
2321
});
2422
});
23+
24+
25+
export const getTopicById = createAction(types.GET_TOPIC_BY_ID, topicService.req.getTopicById, (id)=> {
26+
return {
27+
id
28+
}
29+
});
30+
31+
32+
export const removeTopicCacheById = createAction(types.REMOVE_TOPIC_CACHE_BY_ID, (id)=> {
33+
return {
34+
id
35+
}
36+
});

src/components/CommentOverlay.js

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
import React, {
2+
View,
3+
StyleSheet,
4+
Component,
5+
Text,
6+
PropTypes
7+
} from 'react-native';
8+
import Icon from 'react-native-vector-icons/Ionicons';
9+
import OverlayButton from './base/OverlayButton';
10+
11+
12+
const overlaySize = 45;
13+
const iconSize = 12;
14+
15+
16+
class CommentOverlay extends Component {
17+
static propTypes = {
18+
onPress: PropTypes.func,
19+
replyCount: PropTypes.number
20+
};
21+
22+
23+
static defaultProps = {
24+
replyCount: 0
25+
};
26+
27+
28+
_renderCommentReplyCount(count) {
29+
if (count > 999) {
30+
return '1k+'
31+
}
32+
return count
33+
}
34+
35+
render() {
36+
return (
37+
<OverlayButton
38+
position={styles.position}
39+
onPress={this.props.onPress}>
40+
<View style={styles.content}>
41+
<Icon
42+
name='chatbox'
43+
size={13}
44+
color='white'
45+
style={styles.commentIcon}
46+
/>
47+
<Text style={styles.commentText}>
48+
{this._renderCommentReplyCount(this.props.replyCount)}
49+
</Text>
50+
</View>
51+
</OverlayButton>
52+
)
53+
}
54+
}
55+
56+
const styles = StyleSheet.create({
57+
position: {
58+
right: 20,
59+
bottom: 20
60+
},
61+
commentText: {
62+
textAlign: 'center',
63+
color: 'white',
64+
fontSize: 12,
65+
paddingLeft: 4
66+
},
67+
content: {
68+
height: overlaySize,
69+
width: overlaySize,
70+
borderRadius: overlaySize / 2,
71+
flexDirection: 'row',
72+
justifyContent: 'center',
73+
alignItems: 'center'
74+
},
75+
commentIcon: {
76+
height: iconSize,
77+
width: iconSize,
78+
}
79+
});
80+
81+
82+
export default CommentOverlay;

src/components/TopicList.js

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ const { height, width } = Dimensions.get('window');
1616

1717
class TopicList extends Component {
1818
static propTypes = {
19-
data: PropTypes.array
19+
data: PropTypes.array,
20+
router: PropTypes.object
2021
};
2122

2223

@@ -34,11 +35,6 @@ class TopicList extends Component {
3435
}
3536

3637

37-
componentDidMount() {
38-
39-
}
40-
41-
4238
componentWillReceiveProps(nextProps) {
4339
if (nextProps.data !== this.props.data) {
4440
this.setState({
@@ -114,6 +110,12 @@ class TopicList extends Component {
114110
<TopicRow
115111
key={topic.id}
116112
topic={topic}
113+
onPress={(topic)=>{
114+
this.props.router.toTopic({
115+
id: topic.id,
116+
topic
117+
});
118+
}}
117119
footer={this._renderTopicFooter(topic)}/>
118120
)
119121
}
@@ -123,26 +125,15 @@ class TopicList extends Component {
123125
return (
124126
<View style={styles.container}>
125127
<ListView
128+
showsVerticalScrollIndicator
129+
removeClippedSubviews
126130
ref={view => {this._listView = view}}
127-
showsVerticalScrollIndicator={true}
128131
initialListSize={10}
129132
pagingEnabled={false}
130-
removeClippedSubviews={true}
133+
scrollRenderAheadDistance={90}
131134
dataSource={this.state.ds}
132135
renderRow={this.renderRow.bind(this)}
133-
scrollRenderAheadDistance={90}
134136
onScroll={this._onScroll.bind(this)}
135-
onResponderReject={(e)=>{
136-
console.log('onResponderReject');
137-
return false;
138-
}}
139-
onResponderRelease={(e)=>{
140-
console.log('release');
141-
}}
142-
onResponderTerminationRequest={(e)=>{
143-
console.log('onResponderTerminationRequest');
144-
return false
145-
}}
146137
/>
147138
</View>
148139
)

src/components/TopicRow.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,13 @@ const { width } = Dimensions.get('window');
1717
class TopicRow extends Component {
1818
static propTypes = {
1919
topic: PropTypes.object,
20-
footer: PropTypes.node
20+
footer: PropTypes.node,
21+
onPross: PropTypes.func
22+
};
23+
24+
25+
static defaultProps = {
26+
onPross: ()=>null
2127
};
2228

2329

0 commit comments

Comments
 (0)