mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-04-27 21:08:02 +08:00
feat: add a prop to specify options for all screens (#47)
* feat: add material top tab integration * feat: add a prop to specify options for all screens
This commit is contained in:
committed by
Michał Osadnik
parent
601cbefd36
commit
217f15d925
@@ -76,6 +76,13 @@ export type DefaultRouterOptions = {
|
||||
initialRouteName?: string;
|
||||
};
|
||||
|
||||
export type DefaultNavigatorOptions<
|
||||
ScreenOptions extends object
|
||||
> = DefaultRouterOptions & {
|
||||
children: React.ReactNode;
|
||||
screenOptions?: ScreenOptions;
|
||||
};
|
||||
|
||||
export type RouterFactory<
|
||||
State extends NavigationState,
|
||||
Action extends NavigationAction,
|
||||
|
||||
@@ -19,6 +19,7 @@ type Options<ScreenOptions extends object> = {
|
||||
state: NavigationState | PartialState<NavigationState>;
|
||||
screens: { [key: string]: RouteConfig<ParamListBase, string, ScreenOptions> };
|
||||
navigation: NavigationHelpers<ParamListBase>;
|
||||
screenOptions?: ScreenOptions;
|
||||
onAction: (
|
||||
action: NavigationAction,
|
||||
visitedNavigators?: Set<string>
|
||||
@@ -38,6 +39,7 @@ export default function useDescriptors<
|
||||
state,
|
||||
screens,
|
||||
navigation,
|
||||
screenOptions,
|
||||
onAction,
|
||||
getState,
|
||||
setState,
|
||||
@@ -91,6 +93,7 @@ export default function useDescriptors<
|
||||
);
|
||||
},
|
||||
options: {
|
||||
...screenOptions,
|
||||
...(typeof screen.options === 'object' || screen.options == null
|
||||
? screen.options
|
||||
: screen.options({
|
||||
|
||||
@@ -11,6 +11,7 @@ import useOnRouteFocus from './useOnRouteFocus';
|
||||
import useChildActionListeners from './useChildActionListeners';
|
||||
import {
|
||||
DefaultRouterOptions,
|
||||
DefaultNavigatorOptions,
|
||||
NavigationState,
|
||||
ParamListBase,
|
||||
RouteConfig,
|
||||
@@ -18,10 +19,6 @@ import {
|
||||
RouterFactory,
|
||||
} from './types';
|
||||
|
||||
type Options = {
|
||||
children: React.ReactNode;
|
||||
};
|
||||
|
||||
const isArrayEqual = (a: any[], b: any[]) =>
|
||||
a.length === b.length && a.every((it, index) => it === b[index]);
|
||||
|
||||
@@ -70,7 +67,7 @@ export default function useNavigationBuilder<
|
||||
RouterOptions extends DefaultRouterOptions
|
||||
>(
|
||||
createRouter: RouterFactory<State, any, RouterOptions>,
|
||||
options: Options & RouterOptions
|
||||
options: DefaultNavigatorOptions<ScreenOptions> & RouterOptions
|
||||
) {
|
||||
useRegisterNavigator();
|
||||
|
||||
@@ -208,6 +205,7 @@ export default function useNavigationBuilder<
|
||||
state,
|
||||
screens,
|
||||
navigation,
|
||||
screenOptions: options.screenOptions,
|
||||
onAction,
|
||||
getState,
|
||||
setState,
|
||||
|
||||
Reference in New Issue
Block a user