Skip to content
This repository was archived by the owner on Nov 12, 2019. It is now read-only.

Commit 3e1ab13

Browse files
committed
girls page
1 parent a441423 commit 3e1ab13

File tree

6 files changed

+214
-86
lines changed

6 files changed

+214
-86
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ A cross platform App which shows the data from [gank.io](http://gank.io)
2222

2323
# Feature and Screenshot
2424

25-
#### iOS user interface on **MoreTab**
25+
#### iOS user interface on MoreTab
2626

2727
![moreTab](https://github.com/wangdicoder/Gank.io/raw/master/screenshot/moretab.png)
2828

js/actions/requestRandomData.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ import * as TYPES from './actionTypes';
77
import fetchUrl from '../constants/fetchUrl';
88
import fetchWithTimeout from '../utils/fetchWithTimeout';
99
import RandomDataDAO from '../dao/RandomDataDAO';
10+
import Toast from 'react-native-root-toast';
11+
import px2dp from '../utils/px2dp';
1012

1113
function fetchSuccess(json) {
1214
return {
1315
type: TYPES.FETCH_RANDOM_DATA_SUCCESS,
14-
dataSource: json
16+
dataSource: json.sort()
1517
};
1618
}
1719

@@ -30,7 +32,7 @@ function fetchRequest() {
3032
function fetchMoreDataSuccess(json) {
3133
return {
3234
type: TYPES.FETCH_RANDOM_MORE_DATA_SUCCESS,
33-
dataSource: json
35+
dataSource: json.sort()
3436
};
3537
}
3638

@@ -63,14 +65,14 @@ export function fetchLocalRandomData() {
6365

6466
export function fetchRandomData(isMoreData=false) {
6567
var results = [];
66-
const randomCategory = ['Android/1','iOS/1','前端/1','休息视频/1','拓展资源/1','App/1','瞎推荐/1'];
68+
const randomCategory = ['Android/2','iOS/2','前端/2','休息视频/2','拓展资源/2','App/2','瞎推荐/2'];
6769
var index = 0;
6870

6971
function fetchCategoryData(dispatch) {
7072
fetchWithTimeout(5000, fetch(fetchUrl.random + randomCategory[Math.floor(Math.random()*7)]))
7173
.then((response)=> response.json())
7274
.then((json) => {
73-
index++;
75+
index += 2;
7476
results = results.concat(json.results);
7577

7678
if(index >= 10) {
@@ -84,6 +86,7 @@ export function fetchRandomData(isMoreData=false) {
8486
}else
8587
fetchCategoryData(dispatch);
8688
}).catch((error) => {
89+
Toast.show('获取数据失败', {position: px2dp(-80)});
8790
if(isMoreData)
8891
dispatch(fetchMoreDataFailure());
8992
else

js/components/ListViewForGirls.js

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
/**
2+
* Created by wangdi on 7/12/16.
3+
*/
4+
import React, {Component, PropTypes} from 'react';
5+
import {StyleSheet, View, Text, Image, ListView, Platform, ActivityIndicator, TouchableNativeFeedback, TouchableHighlight, ToastAndroid} from 'react-native';
6+
import {connect} from 'react-redux';
7+
import theme from '../constants/theme';
8+
import px2dp from '../utils/px2dp';
9+
10+
class ListViewForGirls extends Component{
11+
constructor(props){
12+
super(props);
13+
this.ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
14+
}
15+
16+
static propTypes = {
17+
dataSource: PropTypes.array,
18+
isRenderFooter: PropTypes.bool,
19+
onEndReached: PropTypes.func,
20+
isFullData: PropTypes.bool
21+
};
22+
23+
render(){
24+
return(
25+
<ListView
26+
dataSource={this.ds.cloneWithRows(this.props.dataSource)}
27+
renderRow={this._renderRow.bind(this)}
28+
renderFooter={this._renderFooter.bind(this)}
29+
renderSeparator={this._renderSeparator.bind(this)}
30+
initialListSize={10}
31+
pageSize={10}
32+
onEndReached={this.props.onEndReached}
33+
onEndReachedThreshold={5}
34+
/>
35+
);
36+
}
37+
38+
_renderFooter(){
39+
if(this.props.isRenderFooter) {
40+
if (this.props.isFullData)
41+
return (
42+
<View style={styles.footer}>
43+
<Text style={{color: this.props.tabIconColor}}>已加载全部</Text>
44+
</View>
45+
);
46+
else
47+
return (
48+
<View style={styles.footer}>
49+
<ActivityIndicator
50+
color={this.props.tabIconColor}
51+
/>
52+
<Text style={{marginLeft: 10, color: this.props.tabIconColor}}>拼命获取中...</Text>
53+
</View>
54+
);
55+
}
56+
}
57+
58+
_renderSeparator(sectionID, rowID, adjacentRowHighlighted){
59+
return(
60+
<View key={rowID} style={{height: px2dp(6), backgroundColor: this.props.pageBackgroundColor}}/>
61+
);
62+
}
63+
64+
_renderRow(rowData, sectionID, rowID, highlightRow){
65+
return(
66+
<TouchableHighlight
67+
overflow="hidden"
68+
key={rowID}
69+
onPress={this._itemOnPress.bind(this, rowData)}
70+
underlayColor={theme.touchableHighlightUnderlayColor}>
71+
{this._renderRowContent(rowData)}
72+
</TouchableHighlight>
73+
);
74+
}
75+
76+
_renderRowContent(rowData) {
77+
return (
78+
<View style={styles.rowItem}>
79+
<Image style={{width: theme.screenWidth/2-px2dp(9), height: theme.screenWidth/2, marginRight: 3}}
80+
source={{uri: rowData.leftUrl}}/>
81+
<Image style={{width: theme.screenWidth/2-px2dp(9), height: theme.screenWidth/2, marginLeft: 3}}
82+
source={{uri: rowData.rightUrl}}/>
83+
</View>
84+
);
85+
}
86+
87+
_itemOnPress(rowData){
88+
// this.props.navigator.push({
89+
// component: WebViewPage,
90+
// args: {rowData: rowData}
91+
// });
92+
}
93+
}
94+
95+
const styles = StyleSheet.create({
96+
rowItem: {
97+
flexDirection: 'row',
98+
width: theme.screenWidth,
99+
height: theme.screenWidth/2,
100+
paddingLeft: px2dp(6),
101+
paddingRight: px2dp(6)
102+
},
103+
footer: {
104+
flexDirection: 'row',
105+
width: theme.screenWidth,
106+
height: px2dp(60),
107+
alignItems: 'center',
108+
justifyContent: 'center',
109+
}
110+
});
111+
112+
const mapStateToProps = (state) => {
113+
return {
114+
tabIconColor: state.settingState.colorScheme.tabIconColor,
115+
pageBackgroundColor: state.settingState.colorScheme.pageBackgroundColor,
116+
};
117+
};
118+
119+
export default connect(mapStateToProps)(ListViewForGirls);

js/components/ListViewWithInfo.js

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ class ListViewWithInfo extends Component{
2020

2121
static propTypes = {
2222
dataSource: PropTypes.array,
23-
headerTitle: PropTypes.string,
24-
renderTag: PropTypes.bool,
2523
isRenderFooter: PropTypes.bool,
2624
onEndReached: PropTypes.func,
2725
isFullData: PropTypes.bool,
@@ -33,7 +31,6 @@ class ListViewWithInfo extends Component{
3331
<ListView
3432
dataSource={this.ds.cloneWithRows(this.props.dataSource)}
3533
renderRow={this._renderRow.bind(this)}
36-
renderHeader={this._renderHeader.bind(this)}
3734
renderSeparator={this._renderSeparator.bind(this)}
3835
renderFooter={this._renderFooter.bind(this)}
3936
initialListSize={10}
@@ -103,14 +100,8 @@ class ListViewWithInfo extends Component{
103100
<Text style={[styles.title, {color: titleColor}]} numberOfLines={2}>{rowData.desc}</Text>
104101
</View>
105102
<View style={styles.infoPart}>
106-
{this.props.renderTag ?
107-
<View>
108-
<Icon name="ios-pricetag-outline" color={subTitleColor}/>
109-
<Text style={[styles.detailsLabel, {color: subTitleColor}]}>{rowData.type}</Text>
110-
</View>
111-
:
112-
null
113-
}
103+
<Icon name="ios-pricetag-outline" color={subTitleColor}/>
104+
<Text style={[styles.detailsLabel, {color: subTitleColor}]}>{rowData.type}</Text>
114105
<Icon name="ios-create-outline" color={subTitleColor}/>
115106
<Text style={[styles.detailsLabel, {color: subTitleColor}]}>{rowData.who ? rowData.who : 'null'}</Text>
116107
<Icon name="ios-time-outline" color={subTitleColor}/>
@@ -121,15 +112,6 @@ class ListViewWithInfo extends Component{
121112
);
122113
}
123114

124-
_renderHeader(){
125-
if(this.props.headerTitle)
126-
return(
127-
<View>
128-
<Text>{this.props.headerTitle}</Text>
129-
</View>
130-
);
131-
}
132-
133115
_renderSeparator(sectionID, rowID, adjacentRowHighlighted){
134116
return(
135117
<View key={rowID} style={{height: theme.segment.width, backgroundColor: this.props.segmentColor}}/>

0 commit comments

Comments
 (0)