Skip to content

Commit

Permalink
Export GestureContexts and add missing type for withOrientation, fix …
Browse files Browse the repository at this point in the history
…header back button title prop type
  • Loading branch information
brentvatne committed Mar 19, 2019
1 parent 368b681 commit 4c29c57
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/react-navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,15 @@ module.exports = {
return require('react-navigation-drawer').createDrawerNavigator;
},

// Gesture contexts

get StackGestureContext() {
return require('react-navigation-stack').StackGestureContext;
},
get DrawerGestureContext() {
return require('react-navigation-drawer').DrawerGestureContext;
},

// Routers and Actions

get DrawerRouter() {
Expand Down
18 changes: 17 additions & 1 deletion typescript/react-navigation.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@

declare module 'react-navigation' {
import * as React from 'react';
import { PanGestureHandler } from 'react-native-gesture-handler';

import {
Animated,
TextStyle,
Expand Down Expand Up @@ -1331,7 +1333,7 @@ declare module 'react-navigation' {
export interface HeaderBackButtonProps {
onPress?: () => void;
pressColorAndroid?: string;
title?: string;
title?: string | null;
titleStyle?: StyleProp<TextStyle>;
tintColor?: string;
truncatedTitle?: string;
Expand All @@ -1352,6 +1354,18 @@ declare module 'react-navigation' {
T extends React.ComponentType<any>
> = T extends React.ComponentType<infer P> ? P : never;

export interface NavigationOrientationInjectedProps {
isLandscape: boolean;
}

export function withOrientation<P extends NavigationOrientationInjectedProps>(
Component: React.ComponentType<P>
): React.ComponentType<Omit<P, keyof NavigationOrientationInjectedProps>>;

export interface NavigationInjectedProps<P = NavigationParams> {
navigation: NavigationScreenProp<NavigationRoute<P>, P>;
}

export interface NavigationInjectedProps<P = NavigationParams> {
navigation: NavigationScreenProp<NavigationRoute<P>, P>;
}
Expand Down Expand Up @@ -1428,4 +1442,6 @@ declare module 'react-navigation' {
export const SafeAreaView: React.ComponentClass<SafeAreaViewProps>;

export const NavigationContext: React.Context<NavigationScreenProp<NavigationRoute>>;
export const StackGestureContext: React.Context<React.Ref<PanGestureHandler>>;
export const DrawerGestureContext: React.Context<React.Ref<PanGestureHandler>>;
}

0 comments on commit 4c29c57

Please sign in to comment.