Commit d876b5e9 authored by huanglu's avatar huanglu

feat: init project

parent 78593bf5
...@@ -2,5 +2,18 @@ module.exports = function(api) { ...@@ -2,5 +2,18 @@ module.exports = function(api) {
api.cache(true); api.cache(true);
return { return {
presets: ['babel-preset-expo'], presets: ['babel-preset-expo'],
plugins: [
[
"babel-plugin-root-import",
{
"paths": [
{
"rootPathSuffix": "./src/",
"rootPathPrefix": "@/"
}
]
}
]
]
}; };
}; };
declare module "*.png";
declare module "*.gif";
declare module "*.jpg";
declare module "*.jpeg";
declare module "*.svg";
declare module 'dva-core';
declare module 'dva-loading'
declare module 'dva-immer'
declare module 'react-native-refresh-list-view'
type Action<T> = {
type: string,
payload?: T
}
type Dispatch = (args: {
type: string,
payload: any
}) => Promise<any>
type Reducer<T> = (state: T, action: Action<T>) => T
type EffectsCommandMap = {
put: <A extends Action<any>>(action: A) => any,
call: Function,
select: Function,
take: Function,
cancel: Function,
[key: string]: any,
}
type Effect = (action: Action<any>, effects: EffectsCommandMap) => void
type DvaModel<T> = {
namespace: string,
state: T,
reducers?: {
[key: string]: Reducer<any>
},
effects?: {
[key: string]: Effect
}
}
import { registerRootComponent } from 'expo'; import { registerRootComponent } from 'expo';
import App from './App'; import App from './src/App';
// registerRootComponent calls AppRegistry.registerComponent('main', () => App); // registerRootComponent calls AppRegistry.registerComponent('main', () => App);
// It also ensures that whether you load the app in the Expo client or in a native build, // It also ensures that whether you load the app in the Expo client or in a native build,
......
...@@ -268,6 +268,8 @@ PODS: ...@@ -268,6 +268,8 @@ PODS:
- React-cxxreact (= 0.62.2) - React-cxxreact (= 0.62.2)
- React-jsi (= 0.62.2) - React-jsi (= 0.62.2)
- React-jsinspector (0.62.2) - React-jsinspector (0.62.2)
- react-native-safe-area-context (3.0.7):
- React
- React-RCTActionSheet (0.62.2): - React-RCTActionSheet (0.62.2):
- React-Core/RCTActionSheetHeaders (= 0.62.2) - React-Core/RCTActionSheetHeaders (= 0.62.2)
- React-RCTAnimation (0.62.2): - React-RCTAnimation (0.62.2):
...@@ -327,6 +329,8 @@ PODS: ...@@ -327,6 +329,8 @@ PODS:
- React-cxxreact (= 0.62.2) - React-cxxreact (= 0.62.2)
- React-jsi (= 0.62.2) - React-jsi (= 0.62.2)
- ReactCommon/callinvoker (= 0.62.2) - ReactCommon/callinvoker (= 0.62.2)
- RNCMaskedView (0.1.10):
- React
- RNGestureHandler (1.6.1): - RNGestureHandler (1.6.1):
- React - React
- RNReanimated (1.9.0): - RNReanimated (1.9.0):
...@@ -402,6 +406,7 @@ DEPENDENCIES: ...@@ -402,6 +406,7 @@ DEPENDENCIES:
- React-jsi (from `../node_modules/react-native/ReactCommon/jsi`) - React-jsi (from `../node_modules/react-native/ReactCommon/jsi`)
- React-jsiexecutor (from `../node_modules/react-native/ReactCommon/jsiexecutor`) - React-jsiexecutor (from `../node_modules/react-native/ReactCommon/jsiexecutor`)
- React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector`) - React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector`)
- react-native-safe-area-context (from `../node_modules/react-native-safe-area-context`)
- React-RCTActionSheet (from `../node_modules/react-native/Libraries/ActionSheetIOS`) - React-RCTActionSheet (from `../node_modules/react-native/Libraries/ActionSheetIOS`)
- React-RCTAnimation (from `../node_modules/react-native/Libraries/NativeAnimation`) - React-RCTAnimation (from `../node_modules/react-native/Libraries/NativeAnimation`)
- React-RCTBlob (from `../node_modules/react-native/Libraries/Blob`) - React-RCTBlob (from `../node_modules/react-native/Libraries/Blob`)
...@@ -413,6 +418,7 @@ DEPENDENCIES: ...@@ -413,6 +418,7 @@ DEPENDENCIES:
- React-RCTVibration (from `../node_modules/react-native/Libraries/Vibration`) - React-RCTVibration (from `../node_modules/react-native/Libraries/Vibration`)
- ReactCommon/callinvoker (from `../node_modules/react-native/ReactCommon`) - ReactCommon/callinvoker (from `../node_modules/react-native/ReactCommon`)
- ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`) - ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`)
- "RNCMaskedView (from `../node_modules/@react-native-community/masked-view`)"
- RNGestureHandler (from `../node_modules/react-native-gesture-handler`) - RNGestureHandler (from `../node_modules/react-native-gesture-handler`)
- RNReanimated (from `../node_modules/react-native-reanimated`) - RNReanimated (from `../node_modules/react-native-reanimated`)
- RNScreens (from `../node_modules/react-native-screens`) - RNScreens (from `../node_modules/react-native-screens`)
...@@ -499,6 +505,8 @@ EXTERNAL SOURCES: ...@@ -499,6 +505,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/ReactCommon/jsiexecutor" :path: "../node_modules/react-native/ReactCommon/jsiexecutor"
React-jsinspector: React-jsinspector:
:path: "../node_modules/react-native/ReactCommon/jsinspector" :path: "../node_modules/react-native/ReactCommon/jsinspector"
react-native-safe-area-context:
:path: "../node_modules/react-native-safe-area-context"
React-RCTActionSheet: React-RCTActionSheet:
:path: "../node_modules/react-native/Libraries/ActionSheetIOS" :path: "../node_modules/react-native/Libraries/ActionSheetIOS"
React-RCTAnimation: React-RCTAnimation:
...@@ -519,6 +527,8 @@ EXTERNAL SOURCES: ...@@ -519,6 +527,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/Libraries/Vibration" :path: "../node_modules/react-native/Libraries/Vibration"
ReactCommon: ReactCommon:
:path: "../node_modules/react-native/ReactCommon" :path: "../node_modules/react-native/ReactCommon"
RNCMaskedView:
:path: "../node_modules/@react-native-community/masked-view"
RNGestureHandler: RNGestureHandler:
:path: "../node_modules/react-native-gesture-handler" :path: "../node_modules/react-native-gesture-handler"
RNReanimated: RNReanimated:
...@@ -592,6 +602,7 @@ SPEC CHECKSUMS: ...@@ -592,6 +602,7 @@ SPEC CHECKSUMS:
React-jsi: b6dc94a6a12ff98e8877287a0b7620d365201161 React-jsi: b6dc94a6a12ff98e8877287a0b7620d365201161
React-jsiexecutor: 1540d1c01bb493ae3124ed83351b1b6a155db7da React-jsiexecutor: 1540d1c01bb493ae3124ed83351b1b6a155db7da
React-jsinspector: 512e560d0e985d0e8c479a54a4e5c147a9c83493 React-jsinspector: 512e560d0e985d0e8c479a54a4e5c147a9c83493
react-native-safe-area-context: ef6f16c66b0797ecae1bf86c103dfb3dc16fc33d
React-RCTActionSheet: f41ea8a811aac770e0cc6e0ad6b270c644ea8b7c React-RCTActionSheet: f41ea8a811aac770e0cc6e0ad6b270c644ea8b7c
React-RCTAnimation: 49ab98b1c1ff4445148b72a3d61554138565bad0 React-RCTAnimation: 49ab98b1c1ff4445148b72a3d61554138565bad0
React-RCTBlob: a332773f0ebc413a0ce85942a55b064471587a71 React-RCTBlob: a332773f0ebc413a0ce85942a55b064471587a71
...@@ -602,6 +613,7 @@ SPEC CHECKSUMS: ...@@ -602,6 +613,7 @@ SPEC CHECKSUMS:
React-RCTText: fae545b10cfdb3d247c36c56f61a94cfd6dba41d React-RCTText: fae545b10cfdb3d247c36c56f61a94cfd6dba41d
React-RCTVibration: 4356114dbcba4ce66991096e51a66e61eda51256 React-RCTVibration: 4356114dbcba4ce66991096e51a66e61eda51256
ReactCommon: ed4e11d27609d571e7eee8b65548efc191116eb3 ReactCommon: ed4e11d27609d571e7eee8b65548efc191116eb3
RNCMaskedView: 5a8ec07677aa885546a0d98da336457e2bea557f
RNGestureHandler: 8f09cd560f8d533eb36da5a6c5a843af9f056b38 RNGestureHandler: 8f09cd560f8d533eb36da5a6c5a843af9f056b38
RNReanimated: b5ccb50650ba06f6e749c7c329a1bc3ae0c88b43 RNReanimated: b5ccb50650ba06f6e749c7c329a1bc3ae0c88b43
RNScreens: c526239bbe0e957b988dacc8d75ac94ec9cb19da RNScreens: c526239bbe0e957b988dacc8d75ac94ec9cb19da
......
...@@ -8,6 +8,13 @@ ...@@ -8,6 +8,13 @@
"test": "jest" "test": "jest"
}, },
"dependencies": { "dependencies": {
"@react-native-community/masked-view": "0.1.10",
"@react-navigation/bottom-tabs": "^5.7.2",
"@react-navigation/native": "^5.7.1",
"@react-navigation/stack": "^5.7.1",
"dva-core": "^2.0.2",
"dva-immer": "^0.4.19",
"dva-loading": "^3.0.20",
"expo": "~38.0.1", "expo": "~38.0.1",
"expo-splash-screen": "~0.4.0", "expo-splash-screen": "~0.4.0",
"expo-status-bar": "^1.0.0", "expo-status-bar": "^1.0.0",
...@@ -15,17 +22,32 @@ ...@@ -15,17 +22,32 @@
"react": "~16.11.0", "react": "~16.11.0",
"react-dom": "~16.11.0", "react-dom": "~16.11.0",
"react-native": "~0.62.2", "react-native": "~0.62.2",
"react-native-gesture-handler": "~1.6.1", "react-native-gesture-handler": "~1.6.0",
"react-native-reanimated": "~1.9.0", "react-native-reanimated": "~1.9.0",
"react-native-refresh-list-view": "^1.0.12",
"react-native-safe-area-context": "~3.0.7",
"react-native-screens": "~2.9.0", "react-native-screens": "~2.9.0",
"react-native-scrollable-tab-view": "^1.0.0",
"react-native-unimodules": "~0.10.1", "react-native-unimodules": "~0.10.1",
"react-native-web": "~0.11.7" "react-native-web": "~0.11.7",
"react-redux": "^7.2.0",
"redux": "^4.0.5",
"redux-logger": "^3.0.6"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "~7.9.0", "@babel/core": "~7.9.0",
"@types/jest": "^26.0.5",
"@types/react": "^16.9.43",
"@types/react-native": "^0.63.1",
"@types/react-native-scrollable-tab-view": "^0.10.1",
"@types/react-redux": "^7.1.9",
"@types/react-test-renderer": "^16.9.2",
"@types/redux-logger": "^3.0.8",
"babel-jest": "~25.2.6", "babel-jest": "~25.2.6",
"babel-plugin-root-import": "^6.5.0",
"jest": "~25.2.6", "jest": "~25.2.6",
"react-test-renderer": "~16.11.0" "react-test-renderer": "~16.11.0",
"typescript": "^3.9.7"
}, },
"jest": { "jest": {
"preset": "react-native" "preset": "react-native"
......
import { StatusBar } from 'expo-status-bar'; import { StatusBar } from 'expo-status-bar';
import React from 'react'; import React from 'react';
import { StyleSheet, Text, View } from 'react-native'; import { StyleSheet, Text, View } from 'react-native';
import RouterApp from './router'
import { Provider } from 'react-redux'
import dva from '@/utils/dva'
import models from '@/models/index'
import { SafeAreaProvider } from 'react-native-safe-area-context';
const dvaApp = dva.createApp({
initiakState: {},
models,
})
const store = dvaApp.getStore()
export default function App() { export default function App() {
return ( return (
<View style={styles.container}> <SafeAreaProvider>
<Text>Open up App.js to start working on your app!</Text> <Provider store={store}>
<StatusBar style="auto" /> <RouterApp />
</View> </Provider>
</SafeAreaProvider>
); );
} }
const styles = StyleSheet.create({ const styles = StyleSheet.create({
container: { container: {
flex: 1, flex: 1,
backgroundColor: '#fff', backgroundColor: 'blue',
alignItems: 'center', alignItems: 'center',
justifyContent: 'center', justifyContent: 'center',
}, },
......
import { useNavigation } from "@react-navigation/native"
import { useEffect } from "react"
export const useHeaderShow = (show : boolean, deps = []) => {
const navigation = useNavigation()
useEffect(() => {
navigation.setOptions({
headerShown: show,
title: 'sssssss'
})
}, [show, ...deps])
}
\ No newline at end of file
type HomeState = {
name: string | undefined | null,
age: number
}
const HomeModel: DvaModel<HomeState> = {
namespace: 'home',
state: {
name: ' ',
age: 0
},
reducers: {
changeName(state, action) {
return {
...state,
name: action.payload
}
}
},
effects: {
*fetch(action, { select, take, put }) {
setTimeout(() => {
take({
})
}, 1000);
}
}
}
export default HomeModel
\ No newline at end of file
import HomeModel from './home.model'
export default [
HomeModel
]
\ No newline at end of file
import { push, jump } from "@/utils/routeUtil"
export default {
navigatePersonTab() {
jump('Person')
},
navigateHome(params?: any) {
push('home', params)
},
navigateAbout(params?: any) {
push('Message')
}
}
\ No newline at end of file
import React, { useEffect, useState } from 'react'
import { View, Text, TouchableHighlight } from "react-native";
import { useNavigation, NavigationProp } from '@react-navigation/native';
import { connect } from 'react-redux';
import { useHeaderShow } from '@/hooks';
import ScrollTabView, { DefaultTabBar, ScrollableTabBar } from 'react-native-scrollable-tab-view'
import RefreshListView, { RefreshState } from 'react-native-refresh-list-view'
import navigate from '@/navigate';
type AboutProps = {
dispatch: Dispatch,
home: {
name: string,
age: number
}
[key: string]: any
}
const Page1 = (props: any) => (<View style={{ flex: 1, backgroundColor: 'blue' }}><Text>Page1</Text></View>)
const Page2 = (props: any) => (<View style={{ flex: 1 }}><Text>Page2</Text></View>)
const Page3 = () => (<View style={{ flex: 1 }}><Text>Page3</Text></View>)
const ListView = (props: any) => {
const [list, setList] = useState([1,2,3])
const [refreshState, setRefreshState] = useState(RefreshState.Idle)
useEffect(() => {
console.log(props)
}, [])
const renderItem = (itm: any) => (
<TouchableHighlight underlayColor='#f5f5f5' onPress={() => {
navigate.navigateAbout()
}}>
<View style={{ marginBottom: 15, backgroundColor: 'yellow' }}>
<Text style={{ color: 'red' }}>{JSON.stringify(itm)}</Text>
</View>
</TouchableHighlight>
)
const onHeaderRefresh = () => {
console.log('onHeaderRefresh')
setRefreshState(RefreshState.HeaderRefreshing)
setTimeout(() => {
setList([ 1,2,3 ])
setRefreshState(RefreshState.Idle)
}, 1000);
}
const onFooterRefresh = () => {
console.log('onFooterRefresh')
setRefreshState(RefreshState.FooterRefreshing)
if (list.length >= 5) {
setRefreshState(RefreshState.NoMoreData)
return
}
setTimeout(() => {
setList([ ...list, new Date().getTime() ])
setRefreshState(RefreshState.Idle)
}, 1000);
}
console.log(list)
return (
<View style={{ flex: 1 }}>
<RefreshListView
data={list}
keyExtractor={(index: number) => {
return 'key' + index + 'key'
}}
renderItem={renderItem}
refreshState={refreshState }
onHeaderRefresh={onHeaderRefresh}
onFooterRefresh={onFooterRefresh}
footerRefreshingComponent={
<View style={{ justifyContent: 'center', alignItems: 'center'}}>
<Text style={{ color: 'black' }}>loading...</Text>
</View>
}
/>
</View>
)
}
const About = ({ dispatch, ...otherProps }: AboutProps) => {
const navigation = useNavigation()
useHeaderShow(true)
useEffect(() => {
console.log(otherProps)
return () => {
console.log('about destory')
}
}, [])
return (
<ScrollTabView
style={{ margin: 20, backgroundColor: '#f0f0f0', overflow: 'hidden' }}
renderTabBar={() =><ScrollableTabBar />}
tabBarPosition='top'>
<Page1 tabLabel="React" />
<Page2 tabLabel="Flow" />
<ListView tabLabel="Jest" />
<ListView tabLabel="Jest" />
<ListView tabLabel="Jest" />
<ListView tabLabel="Jest" />
</ScrollTabView>
)
}
About.options = {
headerShown: false
}
export default connect(({home}: any) => {
return {
home
}
})(About as any)
\ No newline at end of file
import React, { useEffect, useState } from 'react'
import { View, Text, Button } from "react-native";
import RefreshListView, { RefreshState } from 'react-native-refresh-list-view'
import { useSafeAreaInsets, SafeAreaView } from 'react-native-safe-area-context'
import { TouchableHighlight } from 'react-native-gesture-handler';
import navigate from '@/navigate';
import { useHeaderShow } from '@/hooks';
import { useNavigation } from '@react-navigation/native';
// Idle (普通状态)
// HeaderRefreshing (头部菊花转圈圈中)
// FooterRefreshing (底部菊花转圈圈中)
// NoMoreData (已加载全部数据)
// Failure (加载失败)
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 () => {
navigation.removeListener('focus', handleFocus)
}
}, [])
const renderItem = (itm: any) => (
<TouchableHighlight underlayColor='#f5f5f5' onPress={() => {
navigate.navigateAbout()
}}>
<View style={{ margin: 10, backgroundColor: 'yellow' }}>
<Text style={{ color: 'red' }}>{JSON.stringify(itm)}</Text>
</View>
</TouchableHighlight>
)
const onHeaderRefresh = () => {
setRefreshState(RefreshState.HeaderRefreshing)
setTimeout(() => {
setList([ 1,2,3 ])
setRefreshState(RefreshState.Idle)
}, 1000);
}
const onFooterRefresh = () => {
console.log('onFooterRefresh')
setRefreshState(RefreshState.FooterRefreshing)
if (list.length >= 5) {
setRefreshState(RefreshState.NoMoreData)
return
}
setTimeout(() => {
setList([ ...list, new Date().getTime() ])
setRefreshState(RefreshState.Idle)
}, 1000);
}
console.log(list)
return (
<View style={{ flex: 1 }}>
<RefreshListView
data={list}
keyExtractor={(index: number) => {
return 'key' + index + 'key'
}}
renderItem={renderItem}
refreshState={ refreshState }
onHeaderRefresh={onHeaderRefresh}
onFooterRefresh={onFooterRefresh}
footerRefreshingComponent={
<View style={{ justifyContent: 'center', alignItems: 'center'}}>
<Text style={{ color: 'black' }}>loading...</Text>
</View>
}
/>
</View>
)
}
export default Home
\ No newline at end of file
import React from 'react'
import { View, Text, Button } from "react-native"
import navigate from '@/navigate'
export default (props: any) => {
return (
<View>
<Text>this is message page </Text>
<Button onPress={() => {
navigate.navigatePersonTab()
}} title='person'></Button>
</View>
)
}
\ No newline at end of file
import React, { useEffect } from 'react'
import { View, Text } from "react-native";
export default ({ navigation }: any) => {
useEffect(() => {
console.log(navigation.setOptions)
navigation.setOptions({
tabBarBadge: 8
})
}, [])
return (
<View style={{ flex: 1, backgroundColor: 'blue' }}>
<Text> person </Text>
</View>
)
}
\ No newline at end of file
import React, { useEffect } 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()
const configtabChildren = (components: [BaseRouteConfig]) => {
const stacks = components.map(com => {
return (
<Stack.Screen key={com.name} name={com.name} component={com.component as any} options={{
...com.options || {}
}} />
)
})
return stacks
}
const tabRouterNames = routes.tabs.map(itm => itm.name)
const tabs = (routes.tabs || []).map((tab, index) => {
const Child = () => {
return <Stack.Navigator>
{ configtabChildren(tab.children || [] as any) }
</Stack.Navigator>
}
return (
<Tab.Screen name={tab.name} key={index}
options={({route}) => {
const routeName = getFocusedRouteNameFromRoute(route)
const hiddenTabBar = tabRouterNames.includes(routeName)
return {
tabBarVisible: hiddenTabBar,
...tab.options || {}
}
}}
component={Child} />
)
})
const RouteApp = () => {
return (
<NavigationContainer ref={ref => TopStackNavigationRef(ref)}>
<Tab.Navigator tabBarOptions={{
}}>
{ tabs }
</Tab.Navigator>
</NavigationContainer>
)
}
export default RouteApp
\ No newline at end of file
import React from 'react'
import Home from '@/pages/home'
import About from '@/pages/about'
import Person from '@/pages/person'
import Message from '@/pages/message'
import { StackNavigationOptions } from '@react-navigation/stack'
import { BottomTabNavigationOptions } from '@react-navigation/bottom-tabs'
import { ConnectedComponent } from 'react-redux'
import { View } from 'react-native'
export type BaseRouteConfig = {
name: string,
component?: React.ReactNode | JSX.Element | ConnectedComponent<any, any>,
title?: string,
options?: StackNavigationOptions,
children?: Array<BaseRouteConfig>,
}
export type TabRouteCofnig = BaseRouteConfig & {
options?: BottomTabNavigationOptions,
}
const routesConfig: {
tabs: Array<TabRouteCofnig>
} = {
tabs: [
{
title: 'home',
name: 'Home',
options: {
tabBarLabel: 'home',
tabBarIcon: (props) => <View style={{ width: 30, height: 30, backgroundColor: 'blue' }}></View>,
tabBarBadge: 4
},
children: [
{
component: Home,
name: 'Home',
},
{
name: 'Message',
component: Message,
}
]
},
{
title: 'About',
name: 'About',
children: [
{
name: 'About',
component: About,
},
{
name: 'Message',
component: Message,
}
]
},
{
title: 'Person',
name: 'Person',
children: [
{
name: 'Person',
component: Person,
},
{
name: 'Message',
component: Message,
}
]
}
]
}
export default routesConfig
\ No newline at end of file
import { create } from 'dva-core';
import createLoading from 'dva-loading'
import immer from 'dva-immer'
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;
}
export default {
createApp,
getDispatch() {
return app.dispatch;
},
};
\ No newline at end of file
import { NavigationContainerRef, StackActions, TabActions } from '@react-navigation/native';
let NavigationService: NavigationContainerRef;
export const TopStackNavigationRef = (ref: any) => NavigationService = ref
export const push = (name = '', params = {}) => {
NavigationService.dispatch(
StackActions.push(name, params)
)
}
export const replace = (name = '', params = {}) => {
NavigationService.dispatch(
StackActions.replace(name, params)
)
}
export const back = (count = 1) => {
NavigationService.dispatch(
StackActions.pop(count)
)
}
export const backRoot = () => {
NavigationService.dispatch(
StackActions.popToTop()
)
}
export const jump = (name) => {
NavigationService.dispatch(
TabActions.jumpTo(name)
)
}
{
"compilerOptions": {
"allowJs": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"isolatedModules": true,
"jsx": "react",
"lib": ["es6"],
"moduleResolution": "node",
"noEmit": true,
"strict": false,
"target": "esnext",
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
},
"exclude": [
"node_modules",
"babel.config.js",
"metro.config.js",
"jest.config.js"
]
}
This diff is collapsed.
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