Skip to content

Commit a3ec228

Browse files
committed
update router component
1 parent 2f94ba3 commit a3ec228

Some content is hidden

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

81 files changed

+478
-884
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
"react-native-html-converter": "^1.0.4",
4646
"react-native-parallax-scroll-view": "^0.19.0",
4747
"react-native-scrollable-tab-view": "^0.5.1",
48-
"react-native-simple-markdown": "^1.0.54",
4948
"react-native-toast": "^1.0.1",
5049
"react-native-vector-icons": "^2.0.3",
5150
"react-redux": "^4.4.5",

source/component/button/home.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
11
import React, { Component } from 'react';
22
import {
3-
View,
4-
Image,
53
StyleSheet,
64
} from 'react-native';
75
import TimerMixin from 'react-timer-mixin';
86
import ActionButton from 'react-native-action-button';
97
import Icon from 'react-native-vector-icons/Ionicons';
8+
import ViewPage from '../view';
109
import { ComponentStyles, StyleConfig } from '../../style';
1110

1211
const buttons = [{
1312
title:'闪存',
1413
icon: 'ios-color-palette-outline',
15-
action:'toBlinkAdd',
14+
action:'push',
15+
view: 'blinkAdd',
1616
color: StyleConfig.color_primary
1717
},{
1818
title:'博问',
1919
icon: 'ios-document-outline',
20-
action:'toQuestionAdd',
20+
action:'push',
21+
view: 'questionAdd',
2122
color: StyleConfig.color_primary
2223
}];
2324

2425
class HomeButton extends Component {
2526

2627
constructor(props) {
2728
super(props);
28-
this.state = {
29-
activeButton: null
30-
};
3129
}
3230

3331
componentWillUnmount() {
34-
TimerMixin.clearTimeout(this.timer);
32+
this.timer && TimerMixin.clearTimeout(this.timer);
3533
}
3634

3735
onButtonPress(item){
38-
let { router } = this.props;
39-
this.timer = TimerMixin.setTimeout(() => {
40-
router && router[item.action] && router[item.action](item);
41-
}, 500);
36+
const { router } = this.props;
37+
if(router && router[item.action] && ViewPage[item.view]){
38+
this.timer = TimerMixin.setTimeout(() => {
39+
router[item.action](ViewPage[item.view]());
40+
}, 500);
41+
}
4242
}
4343

4444
renderButtonItem(item, index){

source/component/button/post.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import React, { Component } from 'react';
22
import {
3-
View,
4-
Image,
53
StyleSheet,
64
} from 'react-native';
75
import TimerMixin from 'react-timer-mixin';
@@ -30,19 +28,18 @@ class PostButton extends Component {
3028

3129
constructor(props) {
3230
super(props);
33-
this.state = {
34-
activeButton: null
35-
};
3631
}
3732

3833
componentWillUnmount() {
39-
TimerMixin.clearTimeout(this.timer);
34+
this.timer && TimerMixin.clearTimeout(this.timer);
4035
}
4136

4237
onButtonPress(item){
43-
this.timer = TimerMixin.setTimeout(() => {
44-
this.props[item.action] && this.props[item.action](item);
45-
}, 500);
38+
if(this.props[item.action]){
39+
this.timer = TimerMixin.setTimeout(() => {
40+
this.props[item.action](item);
41+
}, 500);
42+
}
4643
}
4744

4845
renderButtonItem(item, index){

source/component/button/single.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
11
import React, { Component } from 'react';
2-
import {
3-
View,
4-
Image,
5-
StyleSheet,
6-
TouchableOpacity
7-
} from 'react-native';
82
import Icon from 'react-native-vector-icons/Ionicons';
93
import ActionButton from 'react-native-action-button';
104
import { ComponentStyles, StyleConfig } from '../../style';
@@ -16,7 +10,7 @@ class SingleButton extends Component {
1610
}
1711

1812
renderButtonIcon(){
19-
let { icon = 'ios-arrow-round-back' } = this.props;
13+
const { icon = 'ios-arrow-round-back' } = this.props;
2014
return (
2115
<Icon
2216
name={ icon }
@@ -26,7 +20,7 @@ class SingleButton extends Component {
2620
}
2721

2822
render() {
29-
let {
23+
const {
3024
onPress = ()=>null,
3125
color = StyleConfig.action_color_primary,
3226
position ='left',

source/component/drawerPanel.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ import { connect } from 'react-redux';
1313
import TimerMixin from 'react-timer-mixin';
1414
import Icon from 'react-native-vector-icons/Ionicons';
1515
import PureRenderMixin from 'react-addons-pure-render-mixin';
16-
import Config, { postCategory } from '../config';
16+
import { postCategory } from '../config';
1717
import drawerItems from '../config/drawer';
1818
import { getImageSource } from '../common';
19+
import ViewPage from './view';
1920
import { CommonStyles, ComponentStyles, StyleConfig } from '../style';
2021

2122
const backgroundImageSource = getImageSource(1);
@@ -30,8 +31,12 @@ class DrawerPanel extends Component {
3031
this.shouldComponentUpdate = PureRenderMixin.shouldComponentUpdate.bind(this);
3132
}
3233

34+
componentWillUnmount() {
35+
this.timer && TimerMixin.clearTimeout(this.timer);
36+
}
37+
3338
onItemPress(item){
34-
let { onDrawerHide, onDrawerPress } = this.props;
39+
const { onDrawerHide, onDrawerPress } = this.props;
3540
if (item.action === "refresh") {
3641
this.setState({
3742
flag: item.flag
@@ -46,25 +51,21 @@ class DrawerPanel extends Component {
4651
}
4752

4853
onUserPress(){
49-
let pressItem = {
50-
action: "toUser",
54+
const pressItem = {
55+
action: "push",
5156
flag:"user"
5257
};
5358
this.onItemPress(pressItem);
5459
}
5560

5661
onAboutPress(){
57-
let pressItem = {
58-
action: "toAbout",
62+
const pressItem = {
63+
action: "push",
5964
flag:"about"
6065
};
6166
this.onItemPress(pressItem);
6267
}
6368

64-
componentWillUnmount() {
65-
TimerMixin.clearTimeout(this.timer);
66-
}
67-
6869
renderHeaderBackground(){
6970
return (
7071
<View>
@@ -120,7 +121,7 @@ class DrawerPanel extends Component {
120121
}
121122

122123
renderHeader(){
123-
let { router } = this.props;
124+
const { router } = this.props;
124125
return (
125126
<View style={ styles.header_container }>
126127
{ this.renderHeaderBackground() }
@@ -130,7 +131,7 @@ class DrawerPanel extends Component {
130131
}
131132

132133
renderNavActiveItem(item, index){
133-
let onDrawerHide = this.props.onDrawerHide || (()=>null);
134+
const onDrawerHide = this.props.onDrawerHide || (()=>null);
134135
return (
135136
<TouchableHighlight
136137
underlayColor ={ StyleConfig.touchable_press_color }

source/component/endtag.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class EndTag extends Component {
1414
}
1515

1616
render() {
17-
let { text = "— 我是有底线的 —" } = this.props;
17+
const { text = "— 我是有底线的 —" } = this.props;
1818
return (
1919
<View style={ [CommonStyles.p_a_4] }>
2020
<Text style={ [CommonStyles.text_center, CommonStyles.text_muted] }>

source/component/header/author.js

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,14 @@ import {
33
View,
44
Image,
55
Text,
6-
Dimensions,
76
ScrollView,
8-
StyleSheet,
9-
TouchableOpacity
7+
StyleSheet
108
} from 'react-native';
119

12-
import _ from 'lodash';
13-
import moment from 'moment';
1410
import ParallaxScrollView from 'react-native-parallax-scroll-view';
15-
import * as Animatable from 'react-native-animatable';
1611
import PureRenderMixin from 'react-addons-pure-render-mixin';
1712
import { CommonStyles, ComponentStyles, StyleConfig } from '../../style';
18-
import { getImageSource, getBloggerAvatar, decodeHTML } from '../../common';
13+
import { getImageSource } from '../../common';
1914
import Navbar from '../navbar';
2015

2116
class AuthorRender extends Component {
@@ -29,7 +24,7 @@ class AuthorRender extends Component {
2924
}
3025

3126
componentDidMount(){
32-
let cover = getImageSource();
27+
const cover = getImageSource();
3328
this.setState({
3429
cover: cover
3530
});
@@ -78,7 +73,7 @@ class AuthorRender extends Component {
7873
}
7974

8075
renderAuthorInfo(){
81-
let { author, avatar } = this.props;
76+
const { author, avatar } = this.props;
8277
return (
8378
<View style={[ CommonStyles.flexColumn, CommonStyles.flexItemsMiddle, CommonStyles.flexItemsCenter, CommonStyles.m_b_4 ]}>
8479
<Image
@@ -92,7 +87,7 @@ class AuthorRender extends Component {
9287
}
9388

9489
renderAuthorMeta(){
95-
let { author, avatar } = this.props;
90+
const { author, avatar } = this.props;
9691
return (
9792
<View style={ [ ComponentStyles.pos_absolute, CommonStyles.p_x_3, CommonStyles.p_y_2, CommonStyles.flexRow, CommonStyles.flexItemsMiddle, CommonStyles.flexItemsBetween, styles.foreground_meta ] }>
9893
<Text style={ [CommonStyles.text_light, CommonStyles.font_xs] }>
@@ -103,7 +98,7 @@ class AuthorRender extends Component {
10398
}
10499

105100
renderParallaxForeground(){
106-
let { author } = this.props;
101+
const { author } = this.props;
107102

108103
if (author && author.title) {
109104
return (
@@ -116,7 +111,7 @@ class AuthorRender extends Component {
116111
}
117112

118113
renderParallaxStickyHeader(){
119-
let { author, avatar } = this.props;
114+
const { author, avatar } = this.props;
120115
if (author && author.title) {
121116
return (
122117
<Navbar
@@ -132,7 +127,8 @@ class AuthorRender extends Component {
132127

133128
return (
134129
<ParallaxScrollView
135-
headerBackgroundColor="#111"
130+
ref={(view)=>{this.parallaxView = view}}
131+
headerBackgroundColor={ StyleConfig.color_dark }
136132
onScroll={(e) => this.onParallaxViewScroll(e) }
137133
stickyHeaderHeight={ StyleConfig.navbar_height }
138134
parallaxHeaderHeight={ StyleConfig.header_height }

source/component/header/favorite.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@ import {
44
Image,
55
Text,
66
ScrollView,
7-
StyleSheet,
8-
TouchableOpacity
7+
StyleSheet
98
} from 'react-native';
109

1110
import _ from 'lodash';
1211
import Icon from 'react-native-vector-icons/Ionicons';
13-
import * as Animatable from 'react-native-animatable';
1412
import PureRenderMixin from 'react-addons-pure-render-mixin';
1513
import ParallaxScrollView from 'react-native-parallax-scroll-view';
1614
import { getImageSource } from '../../common';
@@ -29,7 +27,7 @@ class FavoriteRender extends Component {
2927
}
3028

3129
componentDidMount(){
32-
let cover = getImageSource();
30+
const cover = getImageSource();
3331
this.setState({
3432
cover: cover
3533
});
@@ -65,8 +63,8 @@ class FavoriteRender extends Component {
6563
}
6664

6765
renderPostInfo(){
68-
let { post } = this.props;
69-
let postTitle = _.truncate(post.Title, { length : 50 });
66+
const { post } = this.props;
67+
const postTitle = _.truncate(post.Title, { length : 50 });
7068
return (
7169
<View style={[CommonStyles.m_b_4]}>
7270
<Text style={ [CommonStyles.text_white, CommonStyles.font_eg, CommonStyles.line_height_lg, CommonStyles.text_left] }>
@@ -77,7 +75,7 @@ class FavoriteRender extends Component {
7775
}
7876

7977
renderPostMeta(){
80-
let { post } = this.props;
78+
const { post } = this.props;
8179
return (
8280
<View style={ [ ComponentStyles.pos_absolute, CommonStyles.flexRow, CommonStyles.flexItemsMiddle, CommonStyles.flexItemsBetween, CommonStyles.p_a_3, styles.header_meta ] }>
8381
<Text style={ [ CommonStyles.text_white, CommonStyles.font_sm ] }>
@@ -100,7 +98,7 @@ class FavoriteRender extends Component {
10098
}
10199

102100
renderParallaxStickyHeader(){
103-
let { post } = this.props;
101+
const { post } = this.props;
104102
return (
105103
<Navbar
106104
backgroundImage = { this.state.cover }
@@ -112,8 +110,8 @@ class FavoriteRender extends Component {
112110
render() {
113111
return (
114112
<ParallaxScrollView
115-
headerBackgroundColor="#111"
116-
ref={(view)=>{this.parallaxView = view}}
113+
ref={(view)=>{this.parallaxView = view}}
114+
headerBackgroundColor={ StyleConfig.color_dark }
117115
stickyHeaderHeight={ StyleConfig.navbar_height }
118116
parallaxHeaderHeight={ StyleConfig.header_height }
119117
renderScrollComponent={()=> this.renderParallaxScrollComponent()}

0 commit comments

Comments
 (0)