Skip to content

Commit 46fc078

Browse files
committed
update some page render detail.
1 parent 227db28 commit 46fc078

File tree

29 files changed

+281
-127
lines changed

29 files changed

+281
-127
lines changed

android/app/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ dependencies {
146146
compile 'com.facebook.fresco:animated-gif:0.11.0'
147147
compile "com.facebook.react:react-native:+" // From node_modules
148148
compile project(':react-native-vector-icons')
149+
compile project(':react-native-toast')
149150
}
150151

151152
// Run this once to be able to run the application with BUCK

android/app/src/main/java/com/reactnativecnblogs/MainApplication.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import com.oblador.vectoricons.VectorIconsPackage;
1313
import com.microsoft.codepush.react.CodePush;
14+
import com.remobile.toast.*;
1415

1516
import java.util.Arrays;
1617
import java.util.List;
@@ -33,6 +34,7 @@ protected List<ReactPackage> getPackages() {
3334
return Arrays.<ReactPackage>asList(
3435
new MainReactPackage(),
3536
new VectorIconsPackage(),
37+
new RCTToastPackage(),
3638
new CodePush(BuildConfig.CODEPUSH_KEY, MainApplication.this, BuildConfig.DEBUG)
3739
);
3840
}

android/settings.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@ include ':app'
44
include ':react-native-vector-icons'
55
project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android')
66
include ':react-native-code-push'
7-
project(':react-native-code-push').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-code-push/android/app')
7+
project(':react-native-code-push').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-code-push/android/app')
8+
include ':react-native-toast'
9+
project(':react-native-toast').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-toast/android')

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
"react-native-parallax-scroll-view": "^0.19.0",
4747
"react-native-scrollable-tab-view": "^0.5.1",
4848
"react-native-simple-markdown": "^1.0.54",
49+
"react-native-toast": "^1.0.1",
4950
"react-native-vector-icons": "^2.0.3",
5051
"react-redux": "^4.4.5",
5152
"react-timer-mixin": "^0.13.3",

source/action/comment.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,16 @@ export const getCommentsByPostWithPage = createAction(
3333
}
3434
);
3535

36+
export const addComment = createAction(types.ADD_COMMENT,
37+
async({category, params, data})=>{
38+
return await commentService.addComment(category, params, data);
39+
},
40+
({category, resolved, rejected})=> {
41+
return {
42+
pending: true,
43+
category,
44+
resolved,
45+
rejected
46+
}
47+
}
48+
);

source/action/post.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,15 @@ export const getPostById = createAction(types.FETCH_POST_BY_ID,
4444
);
4545

4646
export const addPost = createAction(types.ADD_POST,
47-
async(category, params)=>{
48-
return await postService.addPost(category, params);
47+
async({category, data})=>{
48+
return await postService.addPost(category, data);
4949
},
50-
(category)=> {
50+
({category, resolved, rejected})=> {
5151
return {
5252
pending: true,
53-
category
53+
category,
54+
resolved,
55+
rejected
5456
}
5557
}
5658
);

source/action/user.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export const getUserInfo = createAction(
4545

4646
export const getUserAssetByCategory = createAction(
4747
types.FETCH_USER_ASSET,
48-
async(category, params)=> {
48+
async(category, params = {})=> {
4949
params.pageIndex = 1;
5050
return await userService.getUserAsset(category, params);
5151
},

source/component/listview/userBlinkRow.js

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class UserBlinkRow extends Component {
2828
blinkInfo.Content = decodeHTML(blink.Content);
2929
blinkInfo.CommentCount = blink.CommentCount;
3030
blinkInfo.Author= decodeHTML(blink.UserDisplayName);
31+
blinkInfo.IsPrivate = blink.IsPrivate;
3132
blinkInfo.Avatar = getBloggerAvatar(blink.UserIconUrl);
3233
blinkInfo.DateAdded = moment(blink.DateAdded).startOf('minute').fromNow();
3334
}
@@ -44,13 +45,19 @@ class UserBlinkRow extends Component {
4445
);
4546
}
4647

47-
renderBlinkMeta(blinkInfo){
48+
renderBlinkDate(blinkInfo){
4849
return (
49-
<View style={ [ CommonStyles.flexRow, CommonStyles.flexItemsBetween ] }>
50+
<View style={ [ CommonStyles.flexRow, CommonStyles.flexItemsMiddle ] }>
5051
<Text style={ [CommonStyles.text_gray, CommonStyles.font_ms] }>
5152
{ blinkInfo.DateAdded }
5253
</Text>
53-
54+
</View>
55+
)
56+
}
57+
58+
renderBlinkComment(blinkInfo){
59+
if(blinkInfo.IsPrivate === false){
60+
return (
5461
<View style={[ CommonStyles.flexRow, CommonStyles.flexItemsMiddle]}>
5562
<Icon
5663
name={ "ios-chatbubbles-outline" }
@@ -60,23 +67,48 @@ class UserBlinkRow extends Component {
6067
{ blinkInfo.CommentCount }
6168
</Text>
6269
</View>
70+
)
71+
}
72+
return (
73+
<View style={[ CommonStyles.flexRow, CommonStyles.flexItemsMiddle]}>
74+
<Icon
75+
name={ "ios-lock-outline" }
76+
size= { StyleConfig.icon_size - 6 }
77+
color={ StyleConfig.color_danger } />
78+
</View>
79+
)
80+
}
81+
82+
renderBlinkMeta(blinkInfo){
83+
return (
84+
<View style={ [ CommonStyles.flexRow, CommonStyles.flexItemsBetween ] }>
85+
{ this.renderBlinkDate(blinkInfo) }
86+
{ this.renderBlinkComment(blinkInfo) }
6387
</View>
6488
);
6589
}
6690

6791
render() {
6892
let blinkInfo = this.getBlinkInfo();
93+
if(blinkInfo.IsPrivate === false){
94+
return (
95+
<TouchableHighlight
96+
onPress={(e)=>{ this.props.onRowPress(blinkInfo) }}
97+
underlayColor={ StyleConfig.touchable_press_color }
98+
key={ blinkInfo.Id }>
99+
<View style={ ComponentStyles.list }>
100+
{ this.renderBlinkContent(blinkInfo) }
101+
{ this.renderBlinkMeta(blinkInfo) }
102+
</View>
103+
</TouchableHighlight>
104+
)
105+
}
69106
return (
70-
<TouchableHighlight
71-
onPress={(e)=>{ this.props.onRowPress(blinkInfo) }}
72-
underlayColor={ StyleConfig.touchable_press_color }
73-
key={ blinkInfo.Id }>
74-
75-
<View style={ ComponentStyles.list }>
76-
{ this.renderBlinkContent(blinkInfo) }
77-
{ this.renderBlinkMeta(blinkInfo) }
78-
</View>
79-
</TouchableHighlight>
107+
<View key = { blinkInfo.Id }
108+
style={ ComponentStyles.list }>
109+
{ this.renderBlinkContent(blinkInfo) }
110+
{ this.renderBlinkMeta(blinkInfo) }
111+
</View>
80112
)
81113
}
82114
}

source/component/panel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Panel extends Component {
1919
renderTitle(){
2020
return (
2121
<View>
22-
<Text style={[ CommonStyles.text_black, CommonStyles.font_md, CommonStyles.line_height_md, this.props.titleStyle ]}>
22+
<Text style={[ CommonStyles.text_danger, CommonStyles.font_sm, CommonStyles.line_height_md, this.props.titleStyle ]}>
2323
{ this.props.title }
2424
</Text>
2525
</View>

source/component/plugin.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import {
77
} from 'react-native';
88
import { bindActionCreators } from 'redux';
99
import { connect } from 'react-redux';
10+
import Toast from 'react-native-toast';
1011
import PureRenderMixin from 'react-addons-pure-render-mixin';
11-
import Toast from './toast';
1212
import * as Updater from '../common/updater';
1313

1414
class Plugin extends Component {
@@ -22,7 +22,7 @@ class Plugin extends Component {
2222
if (this.props.common.message.id !== nextProps.common.message.id) {
2323
let message = nextProps.common.message.text;
2424
if (message && typeof message === "string") {
25-
this.refs.toast.show({message: message});
25+
Toast.show(message);
2626
}
2727
}
2828
}
@@ -32,9 +32,7 @@ class Plugin extends Component {
3232
if (status) {
3333
this.updateHandle();
3434
}else{
35-
this.refs.toast.show({
36-
message : "请检查你的网络连接"
37-
});
35+
Toast.show("请检查你的网络连接");
3836
}
3937
})
4038
}
@@ -61,7 +59,6 @@ class Plugin extends Component {
6159
translucent ={ true }
6260
backgroundColor="rgba(0, 0, 0, 0.2)"
6361
barStyle="light-content" />
64-
<Toast ref="toast"/>
6562
</View>
6663
);
6764
}

source/component/router.js

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ class Router {
3838
BackAndroid.addEventListener("hardwareBackPress", this._onExitApp);
3939
this.timer = TimerMixin.setInterval(() => {
4040
TimerMixin.clearInterval(this.timer);
41-
BackAndroid.removeEventListener("hardwareBackPress", this._onExitApp);
42-
   BackAndroid.addEventListener("hardwareBackPress", this._onHomeBackPress);
41+
BackAndroid.removeEventListener("hardwareBackPress", this._onExitApp);
42+
BackAndroid.addEventListener("hardwareBackPress", this._onHomeBackPress);
4343
}, 2000);
4444
}
4545
 }
@@ -92,7 +92,15 @@ class Router {
9292
}, props);
9393
}
9494

95-
toHome(props) {
95+
toHome(){
96+
this.push({
97+
component: View.Home,
98+
name: 'home',
99+
sceneConfig: RouterSceneConfig.customPushFromRight
100+
}, props);
101+
}
102+
103+
replaceToHome(props) {
96104
this.replace({
97105
component: View.Home,
98106
name: 'home',
@@ -180,7 +188,7 @@ class Router {
180188
}, props);
181189
}
182190

183-
toLogin(props) {
191+
replaceToLogin(props) {
184192
this.replace({
185193
component: View.Login,
186194
name: 'login',
@@ -212,6 +220,14 @@ class Router {
212220
}, props);
213221
}
214222

223+
replaceToUser(props) {
224+
this.replace({
225+
component: View.User,
226+
name: 'user',
227+
sceneConfig: RouterSceneConfig.customPushFromRight
228+
}, props);
229+
}
230+
215231
toUserAsset(props) {
216232
this.push({
217233
component: View.UserAsset,
@@ -220,6 +236,14 @@ class Router {
220236
}, props);
221237
}
222238

239+
replaceToUserAsset(props) {
240+
this.replace({
241+
component: View.UserAsset,
242+
name: 'userAsset',
243+
sceneConfig: RouterSceneConfig.customPushFromRight
244+
}, props);
245+
}
246+
223247
toFavorite(props) {
224248
this.push({
225249
component: View.Favorite,
@@ -237,5 +261,8 @@ class Router {
237261
}
238262
}
239263

264+
export const Pages = {
265+
home: "kangming"
266+
};
240267

241268
export default Router;

source/config/index.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,19 @@
22
export default {
33
appInfo:{
44
name:'博客园',
5-
avatar:'http://123.56.135.166/cnblog/public/img/common/avatar.jpg?v=1.0',
65
descr:'开发者的网上家园',
76
site:'www.cnblogs.com',
8-
version: 'v.1.0.1',
7+
version: 'v3.0.0',
98
copyright: '©2016 powered by react-native',
109
declare: '博客园创立于2004年1月,是一个面向开发者的知识分享社区。自创建以来,博客园一直致力并专注于为开发者打造一个纯净的技术交流社区,推动并帮助开发者通过互联网分享知识,从而让更多开发者从中受益。博客园的使命是帮助开发者用代码改变世界。'
1110
},
1211
authorInfo: {
1312
name:'togayther',
1413
15-
avatar: 'http://123.56.135.166/cnblog/public/img/common/author.jpg',
1614
homepage: 'https://github.com/togayther',
1715
declare: '本软件为个人学习交流作品,内容来源于博客园官方开放接口,版权归博客园及原作者所有。'
1816
},
19-
apiDomain:'https://api.cnblogs.com/',
20-
assetDomain: 'http://123.56.135.166/cnblog',
17+
apiDomain:'https://api.cnblogs.com/'
2118
};
2219

2320
export const postCategory = {

source/constant/actiontype.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export const FETCH_POSTS_BY_CATEGORY = 'FETCH_POSTS_BY_CATEGORY';
55
export const FETCH_POSTS_BY_CATEGORY_WITHPAGE = 'FETCH_POSTS_BY_CATEGORY_WITHPAGE';
66

77
//comment
8+
export const ADD_COMMENT = 'ADD_COMMENT';
89
export const FETCH_COMMENTS_BY_POST = 'FETCH_COMMENTS_BY_POST';
910
export const FETCH_COMMENTS_BY_POST_WITHPAGE = 'FETCH_COMMENTS_BY_POST_WITHPAGE';
1011

source/image/author.jpg

-11.2 KB
Binary file not shown.

source/image/author.png

17.2 KB
Loading

source/reducer/comment.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ export default function (state = {}, action) {
1818
...state,
1919
[id]:state[id].concat(payload)
2020
};
21+
case types.ADD_COMMENT:
22+
return {
23+
...state,
24+
};
2125
default:
2226
return state;
2327
}

source/service/commentService.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ export function getCommentsByPost(category, id, params = {}){
1515
return requestService.get(fetchApi);
1616
}
1717

18-
export function addComent(){
19-
//TODO: 添加评论
18+
export function addComent(category, params, data){
19+
let fetchApi = dataApi[category]["comment_add"];
20+
let strCompiled = _.template(fetchApi);
21+
fetchApi = strCompiled(params);
22+
data = convertJSONToFormData(data);
23+
24+
return requestService.post(fetchApi, data);
2025
}
2126

source/service/request.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ const timeout = 15000;
77

88
function filterJSON(res) {
99
try{
10-
return res.json().then((data)=>{
11-
console.info(data);
12-
});
10+
if(res.headers.get("content-length") > 0){
11+
return res.json();
12+
}
1313
}
1414
catch(e){
1515
throw new Error('data format error');

source/style/index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,15 @@ export const ComponentStyles = StyleSheet.create({
438438
color: StyleConfig.color_dark
439439
},
440440

441+
textarea:{
442+
padding: StyleConfig.space_0,
443+
fontSize: StyleConfig.font_sm,
444+
color: StyleConfig.color_dark,
445+
width: StyleConfig.screen_width - ( StyleConfig.space_3 * 2 ),
446+
textAlign: "left",
447+
textAlignVertical: "top"
448+
},
449+
441450
bar_container:{
442451
position:'absolute',
443452
bottom:0,

0 commit comments

Comments
 (0)