44 */
55
66import React , { useContext , useEffect } from 'react' ;
7+ import { StyleSheet , View } from 'react-native' ;
78
89import BaseContainer from '../../components/BaseContainer' ;
910
@@ -22,6 +23,8 @@ import { StoreContext } from '../../utils/Tool';
2223import { BaseItem } from './BuDeJie/Components/BaseItem' ;
2324import { BuDeJieMobx } from '../../mobx/News' ;
2425
26+ import { TabView , TabBar , SceneMap } from 'react-native-tab-view' ;
27+
2528type typeItem = {
2629 title : string ,
2730 type : RTBuDeJieType | string
@@ -35,8 +38,98 @@ const typeArr: Array<typeItem> = [
3538 { title : '福利' , type : '福利' }
3639];
3740
38- const News = observer(function(props) {
41+ type State = NavigationState< {
42+ key : string ,
43+ title : string
44+ } > ;
45+
46+ class News extends React.Component< { } , State> {
47+ static title = 'Scrollable top bar' ;
48+ static backgroundColor = '#3f51b5' ;
49+ static appbarElevation = 0 ;
50+
51+ constructor ( props : { } ) {
52+ super ( props ) ;
53+ this . state = {
54+ index : 0 ,
55+ routes : [
56+ { key : 'ALL' , title : '全部' , type : 1 } ,
57+ { key : 'VIDEO' , title : '视频' , type : 41 } ,
58+ { key : 'PICTURE' , title : '图片' , type : 10 } ,
59+ { key : 'JOKE' , title : '笑话' , type : 29 } ,
60+ { key : 'WELFARE' , title : '福利' , type : '福利' }
61+ ]
62+ } ;
63+ }
64+ _handleIndexChange = index =>
65+ this . setState ( {
66+ index
67+ } );
68+
69+ _renderTabBar = props => {
70+ console . log ( 'props' , props ) ;
71+ return (
72+ < TabBar
73+ { ...props }
74+ scrollEnabled
75+ indicatorStyle = { styles . indicator }
76+ style = { styles . tabbar }
77+ tabStyle = { styles . tab }
78+ labelStyle = { styles . label }
79+ activeColor = { '#4ECBFC' }
80+ inactiveColor = { 'black' }
81+ // renderIndicator={() => (
82+ // <View style={{backgroundColor: 'red', height: 1, width: SCREEN_WIDTH / 4 }}/>
83+ // )}
84+ />
85+ ) ;
86+ } ;
87+
88+ // _renderScene = SceneMap({
89+ // albums: Welfare,
90+ // contacts: BuDeJie,
91+ // article: BuDeJie,
92+ // chat: BuDeJie
93+ // });
3994
95+ _renderScene = ( { route, jumpTo} ) => {
96+ // console.log('route', route);
97+ switch ( route . key ) {
98+ case 'WELFARE' :
99+ return < Welfare jumpTo = { jumpTo } navigation = { this . props . navigation } type = { route . type } /> ;
100+ default :
101+ return < BuDeJie jumpTo = { jumpTo } navigation = { this . props . navigation } type = { route . type } /> ;
102+ // case 'ALL':
103+ // return
104+ // case 'VIDEO':
105+ // return <BuDeJie jumpTo={jumpTo} navigation={this.props.navigation} type={route.type} />;
106+ // case 'PICTURE':
107+ // return <BuDeJie jumpTo={jumpTo} navigation={this.props.navigation} type={route.type} />;
108+ // case 'JOKE':
109+ // return <BuDeJie jumpTo={jumpTo} navigation={this.props.navigation} type={route.type} />;
110+ //
111+ }
112+ } ;
113+
114+ render ( ) {
115+ return (
116+ < BaseContainer title = { '百思不得姐' } isTopNavigator = { true } >
117+ < TabView
118+ // style={this.props.style}
119+ navigationState = { this . state }
120+ renderScene = { this . _renderScene }
121+ renderTabBar = { this . _renderTabBar }
122+ onIndexChange = { this . _handleIndexChange }
123+ lazy = { true }
124+ swipeDistanceThreshold = { SCREEN_WIDTH / 10 }
125+ initialLayout = { { width : SCREEN_WIDTH } }
126+ />
127+ </ BaseContainer >
128+ ) ;
129+ }
130+ }
131+
132+ const News1 = observer ( function ( props ) {
40133 const store = useContext ( StoreContext ) ;
41134 const { configStore, publicStore, shiTuStore } = store ;
42135 const { navigation } = props ;
@@ -83,4 +176,20 @@ const News = observer(function(props) {
83176 ) ;
84177} );
85178
179+ const styles = StyleSheet.create({
180+ tabbar : {
181+ backgroundColor : 'white'
182+ } ,
183+ tab : {
184+ width : SCREEN_WIDTH / 5
185+ } ,
186+ indicator : {
187+ backgroundColor : '#4ECBFC'
188+ } ,
189+ label : {
190+ fontWeight : 'bold' ,
191+ fontSize : 16
192+ }
193+ } );
194+
86195export { News , Welfare , BuDeJie } ;
0 commit comments