Commit 5ffbf57c authored by huanglu's avatar huanglu

fix: update

parent d876b5e9
......@@ -21,9 +21,7 @@ const HomeModel: DvaModel<HomeState> = {
effects: {
*fetch(action, { select, take, put }) {
setTimeout(() => {
take({
})
}, 1000);
}
}
......
......@@ -16,14 +16,12 @@ import { useNavigation } from '@react-navigation/native';
const Home = (props: any) => {
useHeaderShow(true)
const insets = useSafeAreaInsets()
const [list, setList] = useState([1,2,3])
const [refreshState, setRefreshState] = useState(RefreshState.Idle)
const navigation = useNavigation()
useEffect(() => {
const handleFocus = () => {
console.log('==== home =====')
}
navigation.addListener('focus', handleFocus)
return () => {
......@@ -50,7 +48,6 @@ const Home = (props: any) => {
}
const onFooterRefresh = () => {
console.log('onFooterRefresh')
setRefreshState(RefreshState.FooterRefreshing)
if (list.length >= 5) {
setRefreshState(RefreshState.NoMoreData)
......@@ -62,7 +59,6 @@ const Home = (props: any) => {
}, 1000);
}
console.log(list)
return (
<View style={{ flex: 1 }}>
<RefreshListView
......
import React, { useEffect } from 'react'
import React from 'react'
import { createStackNavigator } from '@react-navigation/stack'
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs'
import { NavigationContainer, getFocusedRouteNameFromRoute } from '@react-navigation/native'
import { TopStackNavigationRef } from '@/utils/routeUtil'
import routes, { BaseRouteConfig } from './routes'
import Home from '@/pages/home'
const Stack = createStackNavigator()
const Tab = createBottomTabNavigator()
......@@ -21,8 +20,6 @@ const configtabChildren = (components: [BaseRouteConfig]) => {
return stacks
}
const tabRouterNames = routes.tabs.map(itm => itm.name)
const tabs = (routes.tabs || []).map((tab, index) => {
const Child = () => {
return <Stack.Navigator>
......@@ -30,10 +27,10 @@ const tabs = (routes.tabs || []).map((tab, index) => {
</Stack.Navigator>
}
return (
<Tab.Screen name={tab.name} key={index}
<Tab.Screen name={tab.name} key={index + 'tab'}
options={({route}) => {
const routeName = getFocusedRouteNameFromRoute(route)
const hiddenTabBar = tabRouterNames.includes(routeName)
const hiddenTabBar = (route as any).state && (route as any).state.index && (route as any).state.index === 0
return {
tabBarVisible: hiddenTabBar,
...tab.options || {}
......@@ -47,6 +44,8 @@ const RouteApp = () => {
return (
<NavigationContainer ref={ref => TopStackNavigationRef(ref)}>
<Tab.Navigator tabBarOptions={{
}} screenOptions={{
tabBarVisible: true,
}}>
{ tabs }
</Tab.Navigator>
......
......@@ -37,6 +37,9 @@ const routesConfig: {
{
component: Home,
name: 'Home',
options: {
}
},
{
name: 'Message',
......@@ -47,6 +50,11 @@ const routesConfig: {
{
title: 'About',
name: 'About',
options: {
tabBarLabel: 'About',
tabBarIcon: (props) => <View style={{ width: 30, height: 30, backgroundColor: 'blue' }}></View>,
tabBarBadge: 4
},
children: [
{
name: 'About',
......@@ -61,14 +69,24 @@ const routesConfig: {
{
title: 'Person',
name: 'Person',
options: {
tabBarLabel: 'Person',
tabBarIcon: (props) => <View style={{ width: 30, height: 30, backgroundColor: 'blue' }}></View>,
tabBarBadge: 4
},
children: [
{
name: 'Person',
component: Person,
options: {
}
},
{
name: 'Message',
component: Message,
options: {
header: null
}
}
]
}
......
......@@ -5,46 +5,46 @@ import { createLogger } from 'redux-logger'
import { Store } from 'redux';
let app: {
use: (arg0: {onError(err: any): void}) => void;
model: (arg0: any) => any;
start: () => void;
_store: Store;
getStore: () => Store;
dispatch: any;
};
let store: Store;
let dispatch;
let registered: boolean;
function createApp(opt: any) {
// redux 的日志
opt.onAction = [createLogger()];
app = create(opt);
app.use(immer());
app.use(createLoading());
app.use({
onError(err: any) {
console.log('dvaError', err);
},
});
if (!registered) {
opt.models.forEach((model: any) => app.model(model));
}
registered = true;
app.start();
store = app._store;
app.getStore = () => store;
dispatch = store.dispatch;
app.dispatch = dispatch;
return app;
use: (arg0: {onError(err: any): void}) => void;
model: (arg0: any) => any;
start: () => void;
_store: Store;
getStore: () => Store;
dispatch: any;
};
let store: Store;
let dispatch;
let registered: boolean;
function createApp(opt: any) {
// redux 的日志
opt.onAction = [createLogger()];
app = create(opt);
app.use(immer());
app.use(createLoading());
app.use({
onError(err: any) {
console.log('dvaError', err);
},
});
if (!registered) {
opt.models.forEach((model: any) => app.model(model));
}
registered = true;
app.start();
store = app._store;
app.getStore = () => store;
dispatch = store.dispatch;
app.dispatch = dispatch;
return app;
}
export default {
createApp,
getDispatch() {
return app.dispatch;
},
};
\ No newline at end of file
export default {
createApp,
getDispatch() {
return app.dispatch;
},
};
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment