Skip to content

Commit 6a90159

Browse files
committed
improve login logic
1 parent d6b5f70 commit 6a90159

23 files changed

+285
-158
lines changed

source/component/bar/blink.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,12 @@ import React, { Component } from 'react';
22
import {
33
Text,
44
View,
5-
Image,
6-
StyleSheet,
7-
ToastAndroid,
85
TouchableOpacity
96
} from 'react-native';
107
import moment from 'moment';
118
import Icon from 'react-native-vector-icons/Ionicons';
129
import PureRenderMixin from 'react-addons-pure-render-mixin';
13-
import { getBloggerName } from '../../common';
14-
import { postCategory, storageKey } from '../../config';
10+
import { postCategory } from '../../config';
1511
import { ComponentStyles, CommonStyles, StyleConfig } from '../../style';
1612

1713
class BlinkBar extends Component {

source/component/bar/offlinePost.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,18 @@ import React, { Component } from 'react';
22
import {
33
Text,
44
View,
5-
Image,
65
Alert,
7-
ToastAndroid,
86
TouchableOpacity
97
} from 'react-native';
108
import moment from 'moment';
119
import Icon from 'react-native-vector-icons/Ionicons';
1210
import PureRenderMixin from 'react-addons-pure-render-mixin';
1311
import { ComponentStyles, StyleConfig } from '../../style';
14-
import { postCategory, storageKey } from '../../config';
1512

1613
class OfflinePostBar extends Component {
1714

1815
constructor(props) {
1916
super(props);
20-
2117
this.shouldComponentUpdate = PureRenderMixin.shouldComponentUpdate.bind(this);
2218
}
2319

source/component/bar/post.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,20 @@ import React, { Component } from 'react';
22
import {
33
Text,
44
View,
5-
Image,
6-
StyleSheet,
7-
ToastAndroid,
85
TouchableOpacity
96
} from 'react-native';
107
import moment from 'moment';
118
import Icon from 'react-native-vector-icons/Ionicons';
129
import PureRenderMixin from 'react-addons-pure-render-mixin';
10+
import Toast from '../toast';
1311
import { getBloggerName } from '../../common';
14-
import { postCategory, storageKey } from '../../config';
12+
import { postCategory } from '../../config';
1513
import { ComponentStyles, CommonStyles, StyleConfig } from '../../style';
1614

1715
class PostBar extends Component {
1816

1917
constructor(props) {
2018
super(props);
21-
2219
this.shouldComponentUpdate = PureRenderMixin.shouldComponentUpdate.bind(this);
2320
}
2421

@@ -46,7 +43,9 @@ class PostBar extends Component {
4643
offlineInfo[post.Id] = {...post, ...offlineData};
4744

4845
offlineAction.savePost(offlineInfo).then(()=>{
49-
ToastAndroid.show("离线保存成功", ToastAndroid.LONG);
46+
this.refs.toast.show({
47+
message: "离线保存成功"
48+
});
5049
});
5150
}
5251
}
@@ -145,6 +144,8 @@ class PostBar extends Component {
145144
{ this.renderCommentItem() }
146145
{ this.renderAuthorItem() }
147146
{ this.renderOfflineItem() }
147+
148+
<Toast ref="toast"/>
148149
</View>
149150
)
150151
}

source/component/bar/postComment.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,17 @@ import React, { Component } from 'react';
22
import {
33
Text,
44
View,
5-
Image,
6-
StyleSheet,
7-
ToastAndroid,
85
TouchableOpacity
96
} from 'react-native';
107
import moment from 'moment';
118
import Icon from 'react-native-vector-icons/Ionicons';
129
import PureRenderMixin from 'react-addons-pure-render-mixin';
13-
import { getBloggerName } from '../../common';
14-
import { postCategory, storageKey } from '../../config';
1510
import { ComponentStyles, CommonStyles, StyleConfig } from '../../style';
1611

1712
class PostCommentBar extends Component {
1813

1914
constructor(props) {
2015
super(props);
21-
2216
this.shouldComponentUpdate = PureRenderMixin.shouldComponentUpdate.bind(this);
2317
}
2418

source/component/bar/question.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import React, { Component } from 'react';
22
import {
33
Text,
44
View,
5-
StyleSheet,
65
TouchableOpacity
76
} from 'react-native';
87
import Icon from 'react-native-vector-icons/Ionicons';

source/component/button/home.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ class HomeButton extends Component {
6060
render() {
6161
return (
6262
<ActionButton
63-
offsetY = { 10 }
64-
offsetX = { 15 }
63+
offsetY = { 0 }
64+
offsetX = { 18 }
6565
icon = { <Icon name="md-create" style={ styles.button_icon } /> }
6666
outRangeScale = { 0.9 }
6767
buttonColor = { 'rgba(199, 85, 74, 0.9)' }>

source/component/drawerPanel.js

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -68,25 +68,37 @@ class DrawerPanel extends Component {
6868
)
6969
}
7070

71+
renderHeaderUserAvatar(){
72+
return (
73+
<Image
74+
style={ [ComponentStyles.avatar, CommonStyles.m_b_3] }
75+
source={{uri:"http://123.56.135.166/cnblog/public/img/common/author.jpg"}}/>
76+
)
77+
}
78+
79+
renderHeaderUserMeta(){
80+
return (
81+
<View style={ [CommonStyles.flexRow, CommonStyles.flexItemsBetween, CommonStyles.flexItemsMiddle] }>
82+
<Text style={ [CommonStyles.text_white, CommonStyles.font_md ] }>
83+
愤怒的晃晃
84+
</Text>
85+
<TouchableOpacity
86+
activeOpacity={ StyleConfig.touchable_press_opacity }
87+
onPress={ ()=> this.onUserPress() }>
88+
<Icon
89+
name={ "ios-log-in-outline" }
90+
size= { StyleConfig.icon_size }
91+
color={ StyleConfig.color_white } />
92+
</TouchableOpacity>
93+
</View>
94+
)
95+
}
96+
7197
renderHeaderForeground(){
7298
return (
7399
<View style={ [ ComponentStyles.pos_absolute, styles.header_content ] }>
74-
<Image
75-
style={ [ComponentStyles.avatar, CommonStyles.m_b_3] }
76-
source={{uri:"http://123.56.135.166/cnblog/public/img/common/author.jpg"}}/>
77-
<View style={ [CommonStyles.flexRow, CommonStyles.flexItemsBetween, CommonStyles.flexItemsMiddle] }>
78-
<Text style={ [CommonStyles.text_white, CommonStyles.font_md ] }>
79-
愤怒的晃晃
80-
</Text>
81-
<TouchableOpacity
82-
activeOpacity={ StyleConfig.touchable_press_opacity }
83-
onPress={ ()=> this.onUserPress() }>
84-
<Icon
85-
name={ "ios-log-in-outline" }
86-
size= { StyleConfig.icon_size }
87-
color={ StyleConfig.color_white } />
88-
</TouchableOpacity>
89-
</View>
100+
{ this.renderHeaderUserAvatar() }
101+
{ this.renderHeaderUserMeta() }
90102
</View>
91103
)
92104
}
@@ -101,7 +113,7 @@ class DrawerPanel extends Component {
101113
)
102114
}
103115

104-
renderActiveItem(item, index){
116+
renderNavActiveItem(item, index){
105117
let onDrawerHide = this.props.onDrawerHide || (()=>null);
106118
return (
107119
<TouchableHighlight
@@ -130,7 +142,7 @@ class DrawerPanel extends Component {
130142
)
131143
}
132144

133-
renderNormalItem(item, index){
145+
renderNavNormalItem(item, index){
134146
return (
135147
<TouchableHighlight
136148
underlayColor ={ StyleConfig.touchable_press_color }
@@ -153,12 +165,12 @@ class DrawerPanel extends Component {
153165
)
154166
}
155167

156-
renderItem(item, index){
168+
renderNavItem(item, index){
157169
let onItemPress;
158170
if (item.flag === this.state.flag) {
159-
return this.renderActiveItem(item, index);
171+
return this.renderNavActiveItem(item, index);
160172
}
161-
return this.renderNormalItem(item, index);
173+
return this.renderNavNormalItem(item, index);
162174
}
163175

164176
renderContent(){
@@ -167,7 +179,7 @@ class DrawerPanel extends Component {
167179
<View style={ [ CommonStyles.p_y_1 ] }>
168180
{
169181
drawerItems.map((nav, index)=>{
170-
return this.renderItem(nav, index);
182+
return this.renderNavItem(nav, index);
171183
})
172184
}
173185
</View>

source/component/endtag.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import React, { Component } from 'react';
22
import {
33
Text,
4-
View,
5-
Image,
6-
StyleSheet,
7-
TouchableOpacity
4+
View
85
} from 'react-native';
96
import PureRenderMixin from 'react-addons-pure-render-mixin';
107
import { CommonStyles } from '../style';

source/component/hintMessage.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import React, { Component } from 'react';
22
import {
33
View,
4-
Text,
5-
Dimensions
4+
Text
65
} from 'react-native';
76

87
import Icon from 'react-native-vector-icons/Ionicons';
@@ -17,12 +16,12 @@ class HintMessage extends Component {
1716
}
1817

1918
render() {
20-
2119
let { message = '- 这里什么都没有 -' } = this.props;
22-
2320
return (
2421
<View style={ [ComponentStyles.message_container] }>
25-
<Text style={ [CommonStyles.text_gray, CommonStyles.font_sm, CommonStyles.text_center ] }>{ message }</Text>
22+
<Text style={ [CommonStyles.text_gray, CommonStyles.font_sm, CommonStyles.text_center ] }>
23+
{ message }
24+
</Text>
2625
</View>
2726
)
2827
}

source/component/imageBox.js

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import React, { Component } from 'react';
22
import {
33
View,
44
Image,
5-
Dimensions,
6-
StyleSheet,
75
ActivityIndicator
86
} from 'react-native';
97
import PureRenderMixin from 'react-addons-pure-render-mixin';
@@ -22,13 +20,10 @@ class ImageBox extends Component {
2220
}
2321

2422
onImageLoadEnd(){
25-
2623
const { uri, maxWidth = defaultMaxWidth } = this.props;
27-
2824
this.setState({
2925
loading: false
3026
});
31-
3227
Image.getSize && Image.getSize(uri, (width, height)=> {
3328
if (width >= maxWidth) {
3429
height = (maxWidth / width) * height;
@@ -44,9 +39,7 @@ class ImageBox extends Component {
4439
}
4540

4641
render() {
47-
4842
const { uri, style } = this.props;
49-
5043
return (
5144
<Image
5245
ref={ view=>this.image = view }
@@ -55,7 +48,7 @@ class ImageBox extends Component {
5548
onLoadEnd={ ()=> this.onImageLoadEnd() }>
5649
{
5750
this.state.loading?
58-
<View style={ styles.progress }>
51+
<View style={[ CommonStyles.flexItemsMiddle, CommonStyles.flexItemsCenter, CommonStyles.flex_1 ]}>
5952
<ActivityIndicator color={ StyleConfig.color_danger }/>
6053
</View>
6154
: null
@@ -65,15 +58,6 @@ class ImageBox extends Component {
6558
}
6659
}
6760

68-
const styles = StyleSheet.create({
69-
progress:{
70-
flex:1,
71-
justifyContent:'center',
72-
alignItems:'center',
73-
backgroundColor:'transparent'
74-
}
75-
});
76-
7761
export default ImageBox;
7862

7963

source/component/navigation.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import React, { Component } from 'react';
22
import {
33
Navigator,
4-
Image,
54
StatusBar,
6-
View,
7-
Dimensions
5+
View
86
} from 'react-native';
97

108
import * as Page from '../view';
@@ -43,15 +41,14 @@ class Navigation extends Component {
4341
wrappedComponent.componentDidFocus();
4442
}
4543
}
46-
4744
route.sceneRef.componentDidFocus && route.sceneRef.componentDidFocus();
4845
}
4946

5047
configureScene(route) {
5148
if (route.sceneConfig) {
5249
return route.sceneConfig
5350
}
54-
return Navigator.SceneConfigs.FloatFromRight
51+
return Navigator.SceneConfigs.PushFromRight
5552
}
5653

5754
render() {

source/component/panel.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ import React, { Component } from 'react';
22
import {
33
View,
44
Text,
5-
Image,
6-
StyleSheet,
7-
ToastAndroid,
85
TouchableHighlight
96
} from 'react-native';
107

@@ -44,15 +41,14 @@ class Panel extends Component {
4441
let { onPress = (()=>null) } = this.props;
4542

4643
return (
47-
<TouchableHighlight
48-
onPress={()=> onPress() }
49-
underlayColor ={ StyleConfig.touchable_press_color }>
44+
<TouchableHighlight
45+
onPress={()=> onPress() }
46+
underlayColor ={ StyleConfig.touchable_press_color }>
5047
<View style = {[ComponentStyles.list, CommonStyles.flexRow, CommonStyles.flexItemsMiddle, CommonStyles.flexItemsBetween]}>
5148
<View style={[ CommonStyles.flexColumn, CommonStyles.flex_4 ]}>
5249
{ this.renderTitle() }
5350
{ this.renderDescr() }
5451
</View>
55-
5652
{
5753
this.props.tailControl?
5854
<View style={[ CommonStyles.flexItemsMiddle, CommonStyles.flex_1 ]}>

0 commit comments

Comments
 (0)