diff --git a/packages/drawer/src/types.tsx b/packages/drawer/src/types.tsx index c863a259..161ab1fd 100644 --- a/packages/drawer/src/types.tsx +++ b/packages/drawer/src/types.tsx @@ -128,10 +128,6 @@ export type DrawerContentComponentProps = T & { * `0` is closed, `1` is open. */ progress: Animated.Node; - /** - * Position of the drawer on the screen. - */ - drawerPosition: 'left' | 'right'; }; export type DrawerContentOptions = { diff --git a/packages/drawer/src/utils/DrawerPositionContext.tsx b/packages/drawer/src/utils/DrawerPositionContext.tsx new file mode 100644 index 00000000..d0b862ab --- /dev/null +++ b/packages/drawer/src/utils/DrawerPositionContext.tsx @@ -0,0 +1,3 @@ +import * as React from 'react'; + +export default React.createContext<'left' | 'right' | undefined>(undefined); diff --git a/packages/drawer/src/views/DrawerContentScrollView.tsx b/packages/drawer/src/views/DrawerContentScrollView.tsx index df2d7a57..43040ee7 100644 --- a/packages/drawer/src/views/DrawerContentScrollView.tsx +++ b/packages/drawer/src/views/DrawerContentScrollView.tsx @@ -1,19 +1,19 @@ import * as React from 'react'; import { ScrollView, StyleSheet, ScrollViewProps } from 'react-native'; import { useSafeArea } from 'react-native-safe-area-context'; +import DrawerPositionContext from '../utils/DrawerPositionContext'; type Props = ScrollViewProps & { - drawerPosition: 'left' | 'right'; children: React.ReactNode; }; export default function DrawerContentScrollView({ contentContainerStyle, style, - drawerPosition, children, ...rest }: Props) { + const drawerPosition = React.useContext(DrawerPositionContext); const insets = useSafeArea(); return ( diff --git a/packages/drawer/src/views/DrawerView.tsx b/packages/drawer/src/views/DrawerView.tsx index de700d0c..5fda313b 100644 --- a/packages/drawer/src/views/DrawerView.tsx +++ b/packages/drawer/src/views/DrawerView.tsx @@ -28,6 +28,7 @@ import { DrawerNavigationHelpers, DrawerContentComponentProps, } from '../types'; +import DrawerPositionContext from '../utils/DrawerPositionContext'; type Props = DrawerNavigationConfig & { state: DrawerNavigationState; @@ -145,14 +146,17 @@ export default function DrawerView({ } const renderNavigationView = ({ progress }: any) => { - return drawerContent({ - ...drawerContentOptions, - progress: progress, - state: state, - navigation: navigation, - descriptors: descriptors, - drawerPosition: drawerPosition, - }); + return ( + + {drawerContent({ + ...drawerContentOptions, + progress: progress, + state: state, + navigation: navigation, + descriptors: descriptors, + })} + + ); }; const renderContent = () => {