feat: add generic type aliases for screen props

closes #7971
This commit is contained in:
Satyajit Sahoo
2020-05-06 19:00:04 +02:00
parent 4d1e102f8c
commit bea14aa26f
10 changed files with 50 additions and 0 deletions

View File

@@ -15,6 +15,7 @@ export { default as BottomTabBar } from './views/BottomTabBar';
export type {
BottomTabNavigationOptions,
BottomTabNavigationProp,
BottomTabScreenProps,
BottomTabBarProps,
BottomTabBarOptions,
} from './types';

View File

@@ -13,6 +13,7 @@ import {
Descriptor,
TabNavigationState,
TabActionHelpers,
RouteProp,
} from '@react-navigation/native';
export type BottomTabNavigationEventMap = {
@@ -45,6 +46,14 @@ export type BottomTabNavigationProp<
> &
TabActionHelpers<ParamList>;
export type BottomTabScreenProps<
ParamList extends ParamListBase,
RouteName extends keyof ParamList = string
> = {
navigation: BottomTabNavigationProp<ParamList, RouteName>;
route: RouteProp<ParamList, RouteName>;
};
export type BottomTabNavigationOptions = {
/**
* Title text for the screen.

View File

@@ -25,6 +25,7 @@ export { default as useIsDrawerOpen } from './utils/useIsDrawerOpen';
export type {
DrawerNavigationOptions,
DrawerNavigationProp,
DrawerScreenProps,
DrawerContentOptions,
DrawerContentComponentProps,
} from './types';

View File

@@ -8,6 +8,7 @@ import {
NavigationHelpers,
DrawerNavigationState,
DrawerActionHelpers,
RouteProp,
} from '@react-navigation/native';
import type { PanGestureHandlerProperties } from 'react-native-gesture-handler';
@@ -208,6 +209,14 @@ export type DrawerNavigationProp<
> &
DrawerActionHelpers<ParamList>;
export type DrawerScreenProps<
ParamList extends ParamListBase,
RouteName extends keyof ParamList = string
> = {
navigation: DrawerNavigationProp<ParamList, RouteName>;
route: RouteProp<ParamList, RouteName>;
};
export type DrawerDescriptor = Descriptor<
ParamListBase,
string,

View File

@@ -14,4 +14,5 @@ export { default as MaterialBottomTabView } from './views/MaterialBottomTabView'
export type {
MaterialBottomTabNavigationOptions,
MaterialBottomTabNavigationProp,
MaterialBottomTabScreenProps,
} from './types';

View File

@@ -6,6 +6,7 @@ import {
NavigationHelpers,
TabNavigationState,
TabActionHelpers,
RouteProp,
} from '@react-navigation/native';
export type MaterialBottomTabNavigationEventMap = {
@@ -32,6 +33,14 @@ export type MaterialBottomTabNavigationProp<
> &
TabActionHelpers<ParamList>;
export type MaterialBottomTabScreenProps<
ParamList extends ParamListBase,
RouteName extends keyof ParamList = string
> = {
navigation: MaterialBottomTabNavigationProp<ParamList, RouteName>;
route: RouteProp<ParamList, RouteName>;
};
export type MaterialBottomTabNavigationOptions = {
/**
* Title text for the screen.

View File

@@ -15,6 +15,7 @@ export { default as MaterialTopTabBar } from './views/MaterialTopTabBar';
export type {
MaterialTopTabNavigationOptions,
MaterialTopTabNavigationProp,
MaterialTopTabScreenProps,
MaterialTopTabBarProps,
MaterialTopTabBarOptions,
} from './types';

View File

@@ -8,6 +8,7 @@ import {
NavigationProp,
TabNavigationState,
TabActionHelpers,
RouteProp,
} from '@react-navigation/native';
export type MaterialTopTabNavigationEventMap = {
@@ -46,6 +47,14 @@ export type MaterialTopTabNavigationProp<
> &
TabActionHelpers<ParamList>;
export type MaterialTopTabScreenProps<
ParamList extends ParamListBase,
RouteName extends keyof ParamList = string
> = {
navigation: MaterialTopTabNavigationProp<ParamList, RouteName>;
route: RouteProp<ParamList, RouteName>;
};
export type MaterialTopTabNavigationOptions = {
/**
* Title text for the screen.

View File

@@ -51,6 +51,7 @@ export { default as useGestureHandlerRef } from './utils/useGestureHandlerRef';
export type {
StackNavigationOptions,
StackNavigationProp,
StackScreenProps,
StackHeaderProps,
StackHeaderLeftButtonProps,
StackHeaderTitleProps,

View File

@@ -15,6 +15,7 @@ import {
NavigationHelpers,
StackNavigationState,
StackActionHelpers,
RouteProp,
} from '@react-navigation/native';
export type StackNavigationEventMap = {
@@ -45,6 +46,14 @@ export type StackNavigationProp<
> &
StackActionHelpers<ParamList>;
export type StackScreenProps<
ParamList extends ParamListBase,
RouteName extends keyof ParamList = string
> = {
navigation: StackNavigationProp<ParamList, RouteName>;
route: RouteProp<ParamList, RouteName>;
};
export type Layout = { width: number; height: number };
export type GestureDirection =