Skip to content

Commit f4c4238

Browse files
committed
handle some user center detail
1 parent dbe8655 commit f4c4238

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+357
-326
lines changed

source/common/index.js

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,36 @@ import moment from 'moment';
88
import Config from '../config';
99
import entities from 'entities';
1010

11-
const imageSourcePath = Config.assetDomain + "/public/img/metarial/";
1211
const bloggerAvatarPath = "https://pic.cnblogs.com/face/";
1312

14-
export function getBloggerName(authorUri) {
15-
authorUri = _.trimEnd(authorUri, '\/');
16-
return authorUri.slice(authorUri.lastIndexOf("\/") + 1);
17-
}
13+
const defaultAvatar = require('../image/avatar.jpg');
14+
15+
const headerImgSource = [
16+
require('../image/header/1.jpg'),
17+
require('../image/header/2.jpg'),
18+
require('../image/header/3.jpg'),
19+
require('../image/header/4.jpg'),
20+
require('../image/header/5.jpg'),
21+
require('../image/header/6.jpg'),
22+
require('../image/header/7.jpg'),
23+
require('../image/header/8.jpg'),
24+
require('../image/header/9.jpg'),
25+
require('../image/header/10.jpg'),
26+
require('../image/header/11.jpg')
27+
];
1828

1929
export function getBloggerAvatar(avatarUri){
20-
if (avatarUri && avatarUri != bloggerAvatarPath && avatarUri.indexOf("sample_face.gif") < 0) {
21-
return avatarUri;
30+
let avatarResult;
31+
if(!avatarUri || (avatarUri === bloggerAvatarPath) || avatarUri.indexOf("sample_face.gif") >= 0){
32+
avatarResult = defaultAvatar;
2233
}
23-
return Config.appInfo.avatar;
24-
}
25-
26-
export function getQuestionAuthorAvatar(avatarName){
27-
if(avatarName && avatarName !== "sample_face.gif"){
28-
return bloggerAvatarPath + avatarName;
34+
else if (!_.startsWith(avatarUri, 'http')){
35+
avatarResult = { uri: bloggerAvatarPath + avatarUri };
2936
}
30-
return Config.appInfo.avatar;
31-
}
32-
33-
export function getBloggerHdpiAvatar(avatarUri){
34-
//deprese
37+
else {
38+
avatarResult = { uri: avatarUri };
39+
}
40+
return avatarResult;
3541
}
3642

3743
export function filterCodeSnippet(codeText) {
@@ -60,12 +66,12 @@ export function decodeHTML(htmlStr) {
6066
return htmlStr;
6167
}
6268

63-
export function getImageSource(key){
64-
let imageLen = 20;
65-
if (!key) {
69+
export function getImageSource(key = -1){
70+
let imageLen = headerImgSource.length;
71+
if (key < 0 || (key > imageLen)) {
6672
key = _.random(1, imageLen - 1);
6773
}
68-
return imageSourcePath + key + ".jpg";
74+
return headerImgSource[key];
6975
}
7076

7177
export function getFormatDate(date){
@@ -77,5 +83,6 @@ export function splitStrToArray(str, char = ',', count = 3){
7783
}
7884

7985
export function numberValidator(str){
80-
return true;
81-
}
86+
let patten = /^[1-9]*[1-9][0-9]*$/;
87+
return patten.test(str);
88+
}

source/component/bar/post.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class PostBar extends Component {
3232
}
3333

3434
onOfflinePress(){
35-
let { post, postContent, category, offlineAction } = this.props;
35+
let { post, postContent, category, onOfflinePress } = this.props;
3636
if (post && postContent) {
3737
let offlineInfo = {};
3838
let offlineData = {
@@ -42,11 +42,7 @@ class PostBar extends Component {
4242
};
4343
offlineInfo[post.Id] = {...post, ...offlineData};
4444

45-
offlineAction.savePost(offlineInfo).then(()=>{
46-
this.refs.toast.show({
47-
message: "离线保存成功"
48-
});
49-
});
45+
onOfflinePress(offlineInfo);
5046
}
5147
}
5248

@@ -144,8 +140,6 @@ class PostBar extends Component {
144140
{ this.renderCommentItem() }
145141
{ this.renderAuthorItem() }
146142
{ this.renderOfflineItem() }
147-
148-
<Toast ref="toast"/>
149143
</View>
150144
)
151145
}

source/component/button/home.js

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,22 @@ import {
77
import TimerMixin from 'react-timer-mixin';
88
import ActionButton from 'react-native-action-button';
99
import Icon from 'react-native-vector-icons/Ionicons';
10-
import { StyleConfig } from '../../style';
10+
import { ComponentStyles, StyleConfig } from '../../style';
1111

1212
const buttons = [{
1313
title:'闪存',
14-
icon: 'md-color-palette',
14+
icon: 'ios-color-palette-outline',
1515
action:'toBlinkAdd',
1616
color: StyleConfig.color_success
1717
},{
1818
title:'博问',
19-
icon: 'md-list-box',
19+
icon: 'ios-document-outline',
2020
action:'toQuestionAdd',
2121
color: StyleConfig.color_warning
2222
}];
2323

24+
const buttonSize = 50;
25+
2426
class HomeButton extends Component {
2527

2628
constructor(props) {
@@ -44,27 +46,34 @@ class HomeButton extends Component {
4446
renderButtonItem(item, index){
4547
return (
4648
<ActionButton.Item
47-
size = { 50 }
49+
size = { buttonSize }
4850
key = { index }
4951
title={ item.title }
5052
titleBgColor = { '#666' }
5153
onPress={() => this.onButtonPress(item) }
5254
buttonColor = { item.color }
5355
style = { styles.button_item }
5456
titleColor = { StyleConfig.color_white }>
55-
<Icon name={ item.icon } style={ styles.button_icon } />
57+
<Icon name={ item.icon } style={ ComponentStyles.button_icon } />
5658
</ActionButton.Item>
5759
)
5860
}
5961

62+
renderButtonIcon(){
63+
return (
64+
<Icon name="ios-add" style={ [ComponentStyles.button_icon, styles.button_icon] }/>
65+
)
66+
}
67+
6068
render() {
6169
return (
6270
<ActionButton
6371
offsetY = { 0 }
64-
offsetX = { 18 }
65-
icon = { <Icon name="md-create" style={ styles.button_icon } /> }
66-
outRangeScale = { 0.9 }
67-
buttonColor = { 'rgba(199, 85, 74, 0.9)' }>
72+
offsetX = { 20 }
73+
size = { buttonSize }
74+
icon = { this.renderButtonIcon() }
75+
btnOutRange = { 'rgba(199, 85, 74, 0.9)' }
76+
buttonColor = { 'rgba(199, 85, 74, 0.5)' }>
6877
{
6978
buttons && buttons.map((button, index)=>{
7079
return this.renderButtonItem(button, index)
@@ -79,13 +88,9 @@ const styles = StyleSheet.create({
7988
button_item:{
8089
elevation: 0
8190
},
82-
button_icon: {
83-
fontSize: 20,
84-
height: 22,
85-
color: '#fff',
86-
},
91+
button_icon:{
92+
fontSize: StyleConfig.icon_size + 6
93+
}
8794
});
8895

89-
export default HomeButton;
90-
91-
96+
export default HomeButton;

source/component/button/single.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import React, { Component } from 'react';
2+
import {
3+
View,
4+
Image,
5+
StyleSheet,
6+
TouchableOpacity
7+
} from 'react-native';
8+
import Icon from 'react-native-vector-icons/Ionicons';
9+
import ActionButton from 'react-native-action-button';
10+
import { ComponentStyles, StyleConfig } from '../../style';
11+
12+
const buttonSize = 50;
13+
14+
class SingleButton extends Component {
15+
16+
constructor(props) {
17+
super(props);
18+
}
19+
20+
renderButtonIcon(){
21+
let { icon = 'ios-menu' } = this.props;
22+
return (
23+
<Icon
24+
name={ icon }
25+
size = { StyleConfig.icon_size }
26+
style={ ComponentStyles.button_icon } />
27+
)
28+
}
29+
30+
render() {
31+
let { onPress = ()=>null, color = 'rgba(60, 177, 158, 0.5)', position ='left' } = this.props;
32+
return (
33+
<ActionButton
34+
offsetY = { 0 }
35+
offsetX = { 20 }
36+
size = { buttonSize }
37+
position={ position }
38+
buttonColor = { color }
39+
onPress = { ()=>onPress() }
40+
icon = { this.renderButtonIcon() }>
41+
</ActionButton>
42+
)
43+
}
44+
}
45+
46+
47+
export default SingleButton;
48+
49+

source/component/drawerPanel.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import drawerItems from '../config/drawer';
1717
import { getImageSource } from '../common';
1818
import { CommonStyles, ComponentStyles, StyleConfig } from '../style';
1919

20-
const backgroundImageSource = getImageSource(2);
20+
const backgroundImageSource = getImageSource(1);
2121

2222
class DrawerPanel extends Component {
2323

@@ -62,7 +62,7 @@ class DrawerPanel extends Component {
6262
<Image
6363
style={[ComponentStyles.header_img]}
6464
resizeMode="stretch"
65-
source={ {uri:backgroundImageSource} }>
65+
source={ backgroundImageSource }>
6666
</Image>
6767
<View style={ ComponentStyles.header_backdrop }/>
6868
</View>
@@ -140,7 +140,7 @@ class DrawerPanel extends Component {
140140
</Text>
141141
</View>
142142
<View>
143-
<Icon name={ "ios-return-right-outline" }
143+
<Icon name={ "ios-checkbox-outline" }
144144
size={ StyleConfig.icon_size }
145145
style={[ CommonStyles.text_danger ]} />
146146
</View>

source/component/endtag.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class EndTag extends Component {
1717
let { text = "— 我是有底线的 —" } = this.props;
1818
return (
1919
<View style={ [CommonStyles.p_a_4] }>
20-
<Text style={ [CommonStyles.text_center, CommonStyles.text_gray] }>
20+
<Text style={ [CommonStyles.text_center, CommonStyles.text_muted] }>
2121
{ text }
2222
</Text>
2323
</View>

source/component/header/author.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class AuthorRender extends Component {
8484
<Animatable.Image
8585
resizeMode="cover"
8686
style={ CommonStyles.headerBackgroundImage }
87-
source={{uri: this.state.cover }}
87+
source={ this.state.cover }
8888
ref={(view)=>{parallaxBackground = view}} >
8989
</Animatable.Image>
9090
<View style={ CommonStyles.headerBackgroundMask }/>
@@ -137,7 +137,7 @@ class AuthorRender extends Component {
137137
renderParallaxStickyHeader(authorInfo){
138138
return (
139139
<Navbar
140-
backgroundImage = { {uri: this.state.cover} }
140+
backgroundImage = { this.state.cover }
141141
leftIconName = { "ios-arrow-round-back" }
142142
leftIconOnPress={ ()=>this.props.router.pop() }
143143
title={ authorInfo.authorName||"返回" }/>

0 commit comments

Comments
 (0)