Skip to content

Commit c088702

Browse files
committed
1. 替换不得姐根路由的react-native-scrollable-tab-view为react-native-tab-view
1 parent a85285f commit c088702

File tree

10 files changed

+1014
-805
lines changed

10 files changed

+1014
-805
lines changed

android/app/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ android {
174174
}
175175

176176
dependencies {
177+
implementation project(':react-native-reanimated')
177178
implementation project(':@react-native-community_netinfo')
178179
implementation project(':@react-native-community_cameraroll')
179180
implementation project(':@react-native-community_async-storage')

android/app/src/main/java/com/shitu/MainApplication.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import android.support.multidex.MultiDex;
66

77
import com.facebook.react.ReactApplication;
8+
import com.swmansion.reanimated.ReanimatedPackage;
89
import com.reactnativecommunity.netinfo.NetInfoPackage;
910
import com.reactnativecommunity.cameraroll.CameraRollPackage;
1011
import com.reactnativecommunity.asyncstorage.AsyncStoragePackage;
@@ -39,6 +40,7 @@ public boolean getUseDeveloperSupport() {
3940
protected List<ReactPackage> getPackages() {
4041
return Arrays.<ReactPackage>asList(
4142
new MainReactPackage(),
43+
new ReanimatedPackage(),
4244
new NetInfoPackage(),
4345
new CameraRollPackage(),
4446
new AsyncStoragePackage(),

android/settings.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
rootProject.name = 'ShiTu'
2+
include ':react-native-reanimated'
3+
project(':react-native-reanimated').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-reanimated/android')
24
include ':@react-native-community_netinfo'
35
project(':@react-native-community_netinfo').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-community/netinfo/android')
46
include ':@react-native-community_cameraroll'

app/mobx/News/BuDeJieMobx.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ class BuDeJieMobx extends ConfigStore {
164164
@action.bound
165165
async fetchBuDeJieData(type: RTBuDeJieType, value: string) {
166166
this.showLoading();
167+
console.log('不得姐加载');
167168
try {
168169
const buDeJieData: RTBDJResult = await loadBuDeJieData(type, value);
169170

app/mobx/News/WelfareMobx.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class WelfareMobx extends ConfigStore {
4747
try {
4848
// 下载图片
4949
await FetchBlob.config(config).fetch('GET', url);
50-
FetchBlob.fs.scanFile([{ path: Dirs.DCIMDir + imageName, mime: '' }])
50+
await FetchBlob.fs.scanFile([{ path: Dirs.DCIMDir + imageName, mime: '' }]);
5151
alert('保存成功');
5252
} catch (e) {
5353
console.log(e);
@@ -58,6 +58,7 @@ class WelfareMobx extends ConfigStore {
5858
@action.bound
5959
async loadWelfareData(type: loadDataType = 'refreshing') {
6060
this.showLoading();
61+
console.log('福利页加载');
6162
this.page = type === 'refreshing' ? 1 : this.page + 1;
6263

6364
try {

app/pages/News/News.js

Lines changed: 110 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55

66
import React, { useContext, useEffect } from 'react';
7+
import { StyleSheet, View } from 'react-native';
78

89
import BaseContainer from '../../components/BaseContainer';
910

@@ -22,6 +23,8 @@ import { StoreContext } from '../../utils/Tool';
2223
import { BaseItem } from './BuDeJie/Components/BaseItem';
2324
import { BuDeJieMobx } from '../../mobx/News';
2425

26+
import { TabView, TabBar, SceneMap } from 'react-native-tab-view';
27+
2528
type 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+
86195
export { News, Welfare, BuDeJie };

app/pages/News/Welfare/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const Welfare = observer(function(props: Props) {
3636
const { publicStore, configStore, shiTuStore } = props;
3737

3838
useEffect(() => {
39-
welfareMobx.loadWelfareData('refreshing');
39+
loadWelfareData('refreshing');
4040
}, []);
4141

4242
function actionSheetToSaveImage(item: RTWeal) {

0 commit comments

Comments
 (0)