33 * Created by Rabbit on 2018/4/12.
44 */
55
6- import React from 'react' ;
6+ import React , { useContext , useEffect } from 'react' ;
77
88import BaseContainer from '../../components/BaseContainer' ;
99
10- import { observer , inject } from 'mobx-react' ;
10+ // import { observer, inject } from 'mobx-react';
11+ import { observer } from 'mobx-react-lite' ;
1112
12- // import ScrollableTabView from '../../components/ScrollableTabView';
1313import ScrollableTabView , { DefaultTabBar } from 'react-native-scrollable-tab-view' ;
1414
1515import { Welfare } from './Welfare' ;
@@ -19,72 +19,66 @@ import { BuDeJieDetail } from './BuDeJieDetail';
1919
2020import type { NavigationState } from 'react-navigation' ;
2121import type { RTBuDeJieType } from '../../servers/News' ;
22-
23- type State = {
24- typeArr : Array < typeItem >
25- } ;
22+ import { StoreContext } from '../../utils/Tool' ;
2623
2724type typeItem = {
2825 title : string ,
29- type : RTBuDeJieType | string ,
30- navigate : NavigationState
26+ type : RTBuDeJieType | string
3127} ;
3228
33- @inject ( 'powerStore' , 'configStore' )
34- @observer
35- class News extends React . Component < any , State > {
36- componentDidMount = async ( ) => {
37- console . log ( 'navigation' , this . props . navigation ) ;
38- this . props . navigation . setParams ( {
39- title : '百思不得姐'
40- } ) ;
41- } ;
29+ const typeArr : Array < typeItem > = [
30+ { title : '福利' , type : '福利' } ,
31+ { title : '笑话' , type : 29 } ,
32+ { title : '图片' , type : 10 } ,
33+ { title : '全部' , type : 1 } ,
34+ { title : '视频' , type : 41 }
35+ ];
36+
37+ const News = observer(function(props) {
38+ const store = useContext ( StoreContext ) ;
39+ const { configStore, publicStore, shiTuStore } = store ;
40+ const { navigate } = props . navigation ;
4241
43- constructor ( props : any ) {
44- super ( props ) ;
45- const { navigate } = this . props . navigation ;
46- this . state = {
47- typeArr : [
48- { title : '笑话' , type : 29 , navigate : navigate } ,
49- { title : '图片' , type : 10 , navigate : navigate } ,
50- { title : '全部' , type : 1 , navigate : navigate } ,
51- { title : '视频' , type : 41 , navigate : navigate } ,
52- { title : '福利' , type : '福利' , navigate : navigate }
53- ]
54- } ;
55- }
42+ console . log ( 'store' , store ) ;
5643
57- render ( ) {
58- return (
59- < BaseContainer title = { '百思不得姐' } isTopNavigator = { true } >
60- < ScrollableTabView
61- renderTabBar = { ( ) => < DefaultTabBar /> }
62- // renderTabBar={() => <ScrollableTabView.DefaultTabBar />}
63- tabBarActiveTextColor = "#4ECBFC"
64- tabBarInactiveTextColor = "black"
65- tabBarBackgroundColor = "white"
66- tabBarUnderlineStyle = { { backgroundColor : '#4ECBFC' , height : 2 } }
67- tabBarTextStyle = { { fontSize : 15 } }
68- >
69- { this . state . typeArr . map ( ( item , i ) => {
70- if ( i === 4 ) {
71- return (
72- < Welfare
73- tabLabel = { item . title }
74- key = { i }
75- navigate = { item . navigate }
76- configStore = { this . props . configStore }
77- powerStore = { this . props . powerStore }
78- />
79- ) ;
80- } else {
81- return < BuDeJie type = { item . type } tabLabel = { item . title } key = { i } navigate = { item . navigate } /> ;
82- }
83- } ) }
84- </ ScrollableTabView >
85- </ BaseContainer >
86- ) ;
87- }
88- }
44+ return (
45+ < BaseContainer title = { '百思不得姐' } isTopNavigator = { true } >
46+ < ScrollableTabView
47+ renderTabBar = { ( ) => < DefaultTabBar /> }
48+ // renderTabBar={() => <ScrollableTabView.DefaultTabBar />}
49+ tabBarActiveTextColor = "#4ECBFC"
50+ tabBarInactiveTextColor = "black"
51+ tabBarBackgroundColor = "white"
52+ tabBarUnderlineStyle = { { backgroundColor : '#4ECBFC' , height : 2 } }
53+ tabBarTextStyle = { { fontSize : 15 } }
54+ >
55+ { typeArr . map ( ( item , i ) => {
56+ if ( i === 0 ) {
57+ return (
58+ < Welfare
59+ tabLabel = { item . title }
60+ key = { i }
61+ navigate = { navigate }
62+ configStore = { configStore }
63+ publicStore = { publicStore }
64+ shiTuStore = { shiTuStore }
65+ />
66+ ) ;
67+ } else {
68+ return (
69+ < BuDeJie
70+ type = { item . type }
71+ tabLabel = { item . title }
72+ key = { i }
73+ navigate = { navigate }
74+ publicStore = { publicStore }
75+ />
76+ ) ;
77+ }
78+ } ) }
79+ </ ScrollableTabView >
80+ </ BaseContainer >
81+ ) ;
82+ } );
8983
9084export { News , Welfare , BuDeJie , BuDeJieDetail } ;
0 commit comments