Skip to content

Commit 72ae4b2

Browse files
febobofebobo
authored andcommitted
lightbox
2 parents 9814516 + 031878a commit 72ae4b2

File tree

12 files changed

+131
-21
lines changed

12 files changed

+131
-21
lines changed

ios/FeInn/AppDelegate.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
3131
* on the same Wi-Fi network.
3232
*/
3333

34-
jsCodeLocation = [NSURL URLWithString:@"http://192.168.1.41:8081/index.ios.bundle?platform=ios&dev=true"];
34+
jsCodeLocation = [NSURL URLWithString:@"http://192.168.1.102:8081/index.ios.bundle?platform=ios&dev=true"];
3535

3636
/**
3737
* OPTION 2

src/actions/ActicleActions.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import * as types from './actionTypes';
2+
import * as acticleService from '../service/acticleService';
3+
import {createAction} from 'redux-actions';
4+
5+
export const getPhoto = createAction(types.GET_PHOTO , acticleService.getPhoto , ({
6+
page,
7+
limit
8+
} , resolved , rejected) => {
9+
resolved && resolved();
10+
})

src/actions/ActionTypes.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ export const REPLY_TOPIC = 'REPLY_TOPIC'; // 评论
88
export const UPS_TOPIC = 'UPS_TOPIC'; // topic 点赞
99
export const GET_TOPIC_DETAIL = 'GET_TOPIC_DETAIL'; // 获取文章详情
1010
export const UP_REPLY = 'UP_REPLY'; // 评论点赞
11+
export const GET_PHOTO = 'GET_PHOTO'; // 评论点赞

src/actions/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ import * as UserActions from './UserActions'
44
import * as TabActions from './TabActions'
55
import * as UtilsActions from './UtilsActions'
66
import * as CommentActions from './CommentActions'
7+
import * as ActicleActions from './ActicleActions'
78

89
export default {
910
...DetailActions,
1011
...EssenceActions,
1112
...TabActions,
1213
...UserActions,
1314
...UtilsActions,
14-
...CommentActions
15+
...CommentActions,
16+
...ActicleActions
1517
}

src/config/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export default {
22
domain : 'https://cnodejs.org/api/v1',
3+
ghDomain : 'http://gank.io/api/data',
34
replySuffix: '\nFrom [变异后的 CNode+](https://github.com/febobo/react-native-redux-FeInn)',
45
}

src/container/tabview.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@ import {
1515
import Icon from 'react-native-vector-icons/Ionicons';
1616
const myIcon = (<Icon name="ios-time" size={30} color="#900" />)
1717
import * as EssencePage from '../page/Essence';
18-
import Article from '../page/Article';
18+
import * as ArticlePage from '../page/Article';
1919
import Welfare from '../page/Welfare';
2020
import * as Login from '../page/Login';
2121
import connectComponent from '../utils/connectComponent';
2222
import TabNavigator from 'react-native-tab-navigator';
2323
import iconHome from '../public/favicon.png';
2424
const Essence = connectComponent(EssencePage);
25+
const Article = connectComponent(ArticlePage);
2526

2627
export default class TabView extends Component {
2728
constructor (props){

src/page/Article.js

Lines changed: 69 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,89 @@ import {
44
Navigator ,
55
View ,
66
Text,
7-
StyleSheet
7+
StyleSheet,
8+
Image,
9+
ScrollView,
10+
TouchableOpacity,
11+
Dimensions
812
} from 'react-native';
913

10-
export default class Article extends Component {
14+
class Article extends Component {
1115
constructor (props){
1216
super(props);
1317
}
1418

19+
componentWillMount(){
20+
const { actions } = this.props;
21+
actions.getPhoto({
22+
page :1,
23+
limit:10
24+
})
25+
}
26+
1527
render (){
28+
console.log(this)
29+
const { Acticle } = this.props;
1630
return (
1731
<View style={[styles.container]}>
18-
<Text style={{fontSize:30,color:'#fff'}}>Hello React-native</Text>
32+
{
33+
Acticle && Acticle.photos && Acticle.photos.length !=0 ?
34+
<ScrollView style={{flex:1}}>
35+
36+
<View style={styles.imgsWrap}>
37+
<View style={styles.imgs}>
38+
{this._renderImg(Acticle.photos.slice(0,5))}
39+
</View>
40+
<View style={styles.imgs}>
41+
{this._renderImg(Acticle.photos.slice(5,10))}
42+
</View>
43+
</View>
44+
</ScrollView> :
45+
<View style={{flexDirection:'row',paddingTop:30,alignItems : 'center',justifyContent : 'center'}}>
46+
<Text style={{fontSize:20}}>说好的妹子呢</Text>
47+
</View>
48+
}
1949
</View>
2050
)
2151
}
22-
}
2352

53+
_renderImg(imgs){
54+
return (
55+
imgs.map( (v,k) =>{
56+
return (
57+
<TouchableOpacity
58+
key={'photo-' + k}
59+
>
60+
<Image
61+
style={{width:width/2,height:parseInt(Math.random() * (width/4) + (width/2))}}
62+
source={{uri : v.url}}
63+
/>
64+
</TouchableOpacity>
65+
)
66+
})
67+
)
68+
}
69+
}
70+
const { width , height } = Dimensions.get('window');
2471
const styles = StyleSheet.create({
2572
container : {
2673
flex : 1,
27-
alignItems : 'center',
28-
justifyContent : 'center',
29-
backgroundColor : 'blue'
30-
}
74+
// alignItems : 'center',
75+
// justifyContent : 'center',
76+
// backgroundColor : 'blue'
77+
},
78+
imgsWrap : {
79+
flex :1,
80+
flexDirection : "row"
81+
},
82+
imgs : {
83+
flex : 1
84+
},
3185
})
86+
87+
export const LayoutComponent = Article;
88+
export function mapStateToProps(state){
89+
return {
90+
Acticle : state.Acticle,
91+
}
92+
}

src/page/Comment.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ class Comment extends Component {
9797
}
9898

9999
_scrollToTop() {
100-
console.log(this._listView)
101100
this._listView.scrollTo({
102101
x: 0,
103102
y: 0

src/reducers/Acticle.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import * as types from '../actions/actionTypes';
2+
3+
export default function Acticle (state={} , action={}){
4+
console.log(action)
5+
const { payload } = action;
6+
switch (action.type) {
7+
case types.GET_PHOTO:
8+
return Object.assign(
9+
{} , state , {
10+
photos : payload
11+
}
12+
)
13+
break;
14+
default:
15+
return state;
16+
}
17+
}

src/reducers/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@ import Detail from './Detail'
44
import Comment from './Comment'
55
import User from './User'
66
import Utils from './Utils'
7+
import Acticle from './Acticle'
8+
79
export {
810
Essence,
911
Tab,
1012
Detail,
1113
Comment,
1214
User,
13-
Utils
15+
Utils,
16+
Acticle
1417
}

0 commit comments

Comments
 (0)