Skip to content

Commit cb11593

Browse files
committed
add some view.
1 parent 5b90408 commit cb11593

34 files changed

+920
-244
lines changed

source/common/index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import React, {
44
} from 'react-native';
55

66
import _ from 'lodash';
7+
import moment from 'moment';
78
import Config from '../config';
89
import entities from 'entities';
910

@@ -16,7 +17,7 @@ export function getBloggerName(authorUri) {
1617
}
1718

1819
export function getBloggerAvatar(avatarUri){
19-
if (avatarUri != bloggerAvatarPath) {
20+
if (avatarUri && avatarUri != bloggerAvatarPath && avatarUri.indexOf("sample_face.gif") < 0) {
2021
return avatarUri;
2122
}
2223
return Config.appInfo.avatar;
@@ -69,7 +70,11 @@ export function getImageSource(key){
6970
if (!key) {
7071
key = _.random(1, imageLen - 1);
7172
}
72-
return imageSourcePath + key + ".jpg?v=1.1";
73+
return imageSourcePath + key + ".jpg";
74+
}
75+
76+
export function getFormatDate(date){
77+
return moment(date).startOf('minute').fromNow();
7378
}
7479

7580
export function splitStrToArray(str, char = ',', count = 3){

source/component/bar/blink.js

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import React, { Component } from 'react';
2+
import {
3+
Text,
4+
View,
5+
Image,
6+
StyleSheet,
7+
ToastAndroid,
8+
TouchableOpacity
9+
} from 'react-native';
10+
import moment from 'moment';
11+
import Icon from 'react-native-vector-icons/Ionicons';
12+
import PureRenderMixin from 'react-addons-pure-render-mixin';
13+
import { getBloggerName } from '../../common';
14+
import { postCategory, storageKey } from '../../config';
15+
import { ComponentStyles, CommonStyles, StyleConfig } from '../../style';
16+
17+
class BlinkBar extends Component {
18+
19+
constructor(props) {
20+
super(props);
21+
this.shouldComponentUpdate = PureRenderMixin.shouldComponentUpdate.bind(this);
22+
}
23+
24+
onCommentPress(){
25+
let { blink, router, category, id } = this.props;
26+
if (router && category && id) {
27+
router.toCommentAdd({
28+
title: blink.Title,
29+
category: category,
30+
id: id
31+
});
32+
}
33+
}
34+
35+
renderReturnItem(){
36+
return (
37+
<TouchableOpacity
38+
onPress={ ()=> this.props.router.pop() }
39+
style={ [ ComponentStyles.bar_item ] }>
40+
<Icon
41+
name='ios-arrow-round-back'
42+
size = { StyleConfig.icon_size }/>
43+
</TouchableOpacity>
44+
);
45+
}
46+
47+
renderCommentItem(){
48+
return (
49+
<TouchableOpacity
50+
onPress = {()=> this.onCommentPress() }
51+
style={ [ ComponentStyles.bar_item ] }>
52+
<Icon
53+
name='ios-chatbubbles-outline'
54+
size = { StyleConfig.icon_size -4 }/>
55+
</TouchableOpacity>
56+
);
57+
}
58+
59+
render() {
60+
return (
61+
<View style={ [ ComponentStyles.bar_container ] }>
62+
{ this.renderReturnItem() }
63+
{ this.renderCommentItem() }
64+
</View>
65+
)
66+
}
67+
}
68+
69+
export default BlinkBar;
70+
71+

source/component/bar/offlinePost.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class OfflinePostBar extends Component {
2323

2424
onRemovePress(){
2525
const { post } = this.props;
26-
if (post && post.id) {
26+
if (post && post.Id) {
2727
Alert.alert(
2828
'系统提示',
2929
'确定要清除该离线博文记录吗?',
@@ -46,10 +46,10 @@ class OfflinePostBar extends Component {
4646
return (
4747
<TouchableOpacity
4848
onPress={ ()=> this.props.router.pop() }
49-
style={ ComponentStyles.barItem }>
49+
style={ [ ComponentStyles.bar_item ] }>
5050
<Icon
5151
name='ios-arrow-round-back'
52-
style={ ComponentStyles.barItemIcon }/>
52+
size={ StyleConfig.icon_size }/>
5353
</TouchableOpacity>
5454
);
5555
}
@@ -58,18 +58,18 @@ class OfflinePostBar extends Component {
5858
return (
5959
<TouchableOpacity
6060
onPress = {()=> this.onRemovePress() }
61-
style={ ComponentStyles.barItem }>
61+
style={ [ ComponentStyles.bar_item ] }>
6262
<Icon
6363
name='ios-trash-outline'
64-
style={ ComponentStyles.barItemIcon }/>
64+
size={ StyleConfig.icon_size }/>
6565
</TouchableOpacity>
6666
);
6767
}
6868

6969
render() {
7070
let { post } = this.props;
7171
return (
72-
<View style={ ComponentStyles.container }>
72+
<View style={ [ ComponentStyles.bar_container ] }>
7373
{ this.renderReturnItem() }
7474
{ this.renderRemoveItem() }
7575
</View>

source/component/bar/post.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@ class PostBar extends Component {
2525
onCommentPress(){
2626
let { post, router, category, id } = this.props;
2727
if (router && category && id) {
28-
router.toComment({
28+
router.toPostComment({
2929
post: post,
30+
blogger: post.blogger,
3031
category: category,
31-
pid: id
32+
id: id
3233
});
3334
}
3435
}
@@ -133,7 +134,6 @@ class PostBar extends Component {
133134
}
134135

135136
render() {
136-
let { post } = this.props;
137137
return (
138138
<View style={ [ ComponentStyles.bar_container ] }>
139139
{ this.renderReturnItem() }

source/component/bar/postComment.js

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import React, { Component } from 'react';
2+
import {
3+
Text,
4+
View,
5+
Image,
6+
StyleSheet,
7+
ToastAndroid,
8+
TouchableOpacity
9+
} from 'react-native';
10+
import moment from 'moment';
11+
import Icon from 'react-native-vector-icons/Ionicons';
12+
import PureRenderMixin from 'react-addons-pure-render-mixin';
13+
import { getBloggerName } from '../../common';
14+
import { postCategory, storageKey } from '../../config';
15+
import { ComponentStyles, CommonStyles, StyleConfig } from '../../style';
16+
17+
class PostCommentBar extends Component {
18+
19+
constructor(props) {
20+
super(props);
21+
22+
this.shouldComponentUpdate = PureRenderMixin.shouldComponentUpdate.bind(this);
23+
}
24+
25+
onCommentPress(){
26+
let { post, router, category, id } = this.props;
27+
if (router && category && id) {
28+
router.toPostComment({
29+
post: post,
30+
blogger: post.blogger,
31+
category: category,
32+
id: id
33+
});
34+
}
35+
}
36+
37+
renderReturnItem(){
38+
return (
39+
<TouchableOpacity
40+
onPress={ ()=> this.props.router.pop() }
41+
style={ [ ComponentStyles.bar_item ] }>
42+
<Icon
43+
name='ios-arrow-round-back'
44+
size = { StyleConfig.icon_size }/>
45+
</TouchableOpacity>
46+
);
47+
}
48+
49+
renderCommentItem(){
50+
return (
51+
<TouchableOpacity
52+
onPress = {()=> this.onCommentPress() }
53+
style={ [ ComponentStyles.bar_item ] }>
54+
<Icon
55+
name='ios-chatbubbles-outline'
56+
size = { StyleConfig.icon_size -4 }/>
57+
</TouchableOpacity>
58+
);
59+
}
60+
61+
render() {
62+
return (
63+
<View style={ [ ComponentStyles.bar_container ] }>
64+
{ this.renderReturnItem() }
65+
{ this.renderCommentItem() }
66+
</View>
67+
)
68+
}
69+
}
70+
71+
export default PostCommentBar;
72+
73+

source/component/bar/question.js

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import React, { Component } from 'react';
2+
import {
3+
Text,
4+
View,
5+
StyleSheet,
6+
TouchableOpacity
7+
} from 'react-native';
8+
import Icon from 'react-native-vector-icons/Ionicons';
9+
import PureRenderMixin from 'react-addons-pure-render-mixin';
10+
import { ComponentStyles, CommonStyles, StyleConfig } from '../../style';
11+
12+
class QuestionBar extends Component {
13+
14+
constructor(props) {
15+
super(props);
16+
this.shouldComponentUpdate = PureRenderMixin.shouldComponentUpdate.bind(this);
17+
}
18+
19+
onCommentPress(){
20+
let { question, router, category, id } = this.props;
21+
if (router && category && id) {
22+
router.toCommentAdd({
23+
title: question.Title,
24+
category: category,
25+
id: id
26+
});
27+
}
28+
}
29+
30+
renderReturnItem(){
31+
return (
32+
<TouchableOpacity
33+
onPress={ ()=> this.props.router.pop() }
34+
style={ [ ComponentStyles.bar_item ] }>
35+
<Icon
36+
name='ios-arrow-round-back'
37+
size = { StyleConfig.icon_size }/>
38+
</TouchableOpacity>
39+
);
40+
}
41+
42+
renderCommentItem(){
43+
return (
44+
<TouchableOpacity
45+
onPress = {()=> this.onCommentPress() }
46+
style={ [ ComponentStyles.bar_item ] }>
47+
<Icon
48+
name='ios-chatbubbles-outline'
49+
size = { StyleConfig.icon_size -4 }/>
50+
</TouchableOpacity>
51+
);
52+
}
53+
54+
render() {
55+
return (
56+
<View style={ [ ComponentStyles.bar_container ] }>
57+
{ this.renderReturnItem() }
58+
{ this.renderCommentItem() }
59+
</View>
60+
)
61+
}
62+
}
63+
64+
export default QuestionBar;
65+
66+

source/component/endtag.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import React, { Component } from 'react';
2+
import {
3+
Text,
4+
View,
5+
Image,
6+
StyleSheet,
7+
TouchableOpacity
8+
} from 'react-native';
9+
import PureRenderMixin from 'react-addons-pure-render-mixin';
10+
import { CommonStyles } from '../style';
11+
12+
class EndTag extends Component {
13+
14+
constructor(props) {
15+
super(props);
16+
this.shouldComponentUpdate = PureRenderMixin.shouldComponentUpdate.bind(this);
17+
}
18+
19+
render() {
20+
let { text = "— END —" } = this.props;
21+
return (
22+
<View style={ [CommonStyles.p_a_4] }>
23+
<Text style={ [CommonStyles.text_center, CommonStyles.text_gray] }>
24+
{ text }
25+
</Text>
26+
</View>
27+
)
28+
}
29+
}
30+
31+
export default EndTag;
32+
33+

0 commit comments

Comments
 (0)