@react-navigation/drawer 6.3.0 → 6.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,7 +13,7 @@ var React = _interopRequireWildcard(require("react"));
13
13
 
14
14
  var _reactNative = require("react-native");
15
15
 
16
- var _reactNativeReanimated = _interopRequireDefault(require("react-native-reanimated"));
16
+ var Reanimated = _interopRequireWildcard(require("react-native-reanimated"));
17
17
 
18
18
  var _reactNativeSafeAreaContext = require("react-native-safe-area-context");
19
19
 
@@ -61,7 +61,7 @@ const getDefaultDrawerWidth = _ref => {
61
61
  const GestureHandlerWrapper = _GestureHandler.GestureHandlerRootView !== null && _GestureHandler.GestureHandlerRootView !== void 0 ? _GestureHandler.GestureHandlerRootView : _reactNative.View;
62
62
 
63
63
  function DrawerViewBase(_ref2) {
64
- var _Animated$isConfigure;
64
+ var _Reanimated$isConfigu;
65
65
 
66
66
  let {
67
67
  state,
@@ -74,7 +74,7 @@ function DrawerViewBase(_ref2) {
74
74
  // @ts-expect-error
75
75
  useLegacyImplementation = !global.nativeCallSyncHook || // Reanimated 2 is not configured
76
76
  // @ts-expect-error: the type definitions are incomplete
77
- !((_Animated$isConfigure = _reactNativeReanimated.default.isConfigured) !== null && _Animated$isConfigure !== void 0 && _Animated$isConfigure.call(_reactNativeReanimated.default))
77
+ !((_Reanimated$isConfigu = Reanimated.isConfigured) !== null && _Reanimated$isConfigu !== void 0 && _Reanimated$isConfigu.call(Reanimated))
78
78
  } = _ref2;
79
79
  const Drawer = useLegacyImplementation ? require('./legacy/Drawer').default : require('./modern/Drawer').default;
80
80
  const focusedRouteKey = state.routes[state.index].key;
@@ -1 +1 @@
1
- {"version":3,"sources":["DrawerView.tsx"],"names":["getDefaultDrawerWidth","height","width","smallerAxisSize","Math","min","isLandscape","isTablet","appBarHeight","Platform","OS","maxWidth","GestureHandlerWrapper","GestureHandlerRootView","View","DrawerViewBase","state","navigation","descriptors","defaultStatus","drawerContent","props","detachInactiveScreens","useLegacyImplementation","global","nativeCallSyncHook","Animated","isConfigured","Drawer","require","default","focusedRouteKey","routes","index","key","drawerHideStatusBarOnOpen","drawerPosition","I18nManager","isRTL","drawerStatusBarAnimation","drawerStyle","drawerType","select","ios","gestureHandlerProps","keyboardDismissMode","overlayColor","swipeEdgeWidth","swipeEnabled","swipeMinDistance","options","loaded","setLoaded","React","useState","includes","dimensions","colors","drawerStatus","handleDrawerOpen","useCallback","dispatch","DrawerActions","openDrawer","target","handleDrawerClose","closeDrawer","useEffect","handleHardwareBack","isFocused","handleEscape","e","subscription","BackHandler","addEventListener","document","body","remove","removeEventListener","renderDrawerContent","renderSceneContent","styles","content","map","route","descriptor","lazy","unmountOnBlur","header","layout","name","headerLeft","sceneContainerStyle","StyleSheet","absoluteFill","zIndex","headerShown","headerTransparent","headerStatusBarHeight","render","backgroundColor","card","borderRightColor","border","borderRightWidth","hairlineWidth","borderLeftColor","borderLeftWidth","DrawerView","rest","create","flex"],"mappings":";;;;;;;AAAA;;AAMA;;AAOA;;AACA;;AAOA;;AACA;;AAWA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AASA,MAAMA,qBAAqB,GAAG,QAMxB;AAAA,MANyB;AAC7BC,IAAAA,MAD6B;AAE7BC,IAAAA;AAF6B,GAMzB;;AACJ;AACF;AACA;AACA;AACA;AACE,QAAMC,eAAe,GAAGC,IAAI,CAACC,GAAL,CAASJ,MAAT,EAAiBC,KAAjB,CAAxB;AACA,QAAMI,WAAW,GAAGJ,KAAK,GAAGD,MAA5B;AACA,QAAMM,QAAQ,GAAGJ,eAAe,IAAI,GAApC;AACA,QAAMK,YAAY,GAAGC,sBAASC,EAAT,KAAgB,KAAhB,GAAyBJ,WAAW,GAAG,EAAH,GAAQ,EAA5C,GAAkD,EAAvE;AACA,QAAMK,QAAQ,GAAGJ,QAAQ,GAAG,GAAH,GAAS,GAAlC;AAEA,SAAOH,IAAI,CAACC,GAAL,CAASF,eAAe,GAA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,\n} from '@react-navigation/elements';\nimport {\n DrawerActions,\n DrawerNavigationState,\n DrawerStatus,\n ParamListBase,\n useTheme,\n} from '@react-navigation/native';\nimport * as React from 'react';\nimport {\n BackHandler,\n I18nManager,\n Platform,\n StyleSheet,\n View,\n} from 'react-native';\nimport Animated from 'react-native-reanimated';\nimport { useSafeAreaFrame } from 'react-native-safe-area-context';\n\nimport type {\n DrawerContentComponentProps,\n DrawerDescriptorMap,\n DrawerHeaderProps,\n DrawerNavigationConfig,\n DrawerNavigationHelpers,\n DrawerNavigationProp,\n DrawerProps,\n} from '../types';\nimport DrawerPositionContext from '../utils/DrawerPositionContext';\nimport DrawerStatusContext from '../utils/DrawerStatusContext';\nimport getDrawerStatusFromState from '../utils/getDrawerStatusFromState';\nimport DrawerContent from './DrawerContent';\nimport DrawerToggleButton from './DrawerToggleButton';\nimport { GestureHandlerRootView } from './GestureHandler';\nimport { MaybeScreen, MaybeScreenContainer } from './ScreenFallback';\n\ntype Props = DrawerNavigationConfig & {\n defaultStatus: DrawerStatus;\n state: DrawerNavigationState<ParamListBase>;\n navigation: DrawerNavigationHelpers;\n descriptors: DrawerDescriptorMap;\n};\n\nconst getDefaultDrawerWidth = ({\n height,\n width,\n}: {\n height: number;\n width: number;\n}) => {\n /*\n * Default drawer width is screen width - header height\n * with a max width of 280 on mobile and 320 on tablet\n * https://material.io/components/navigation-drawer\n */\n const smallerAxisSize = Math.min(height, width);\n const isLandscape = width > height;\n const isTablet = smallerAxisSize >= 600;\n const appBarHeight = Platform.OS === 'ios' ? (isLandscape ? 32 : 44) : 56;\n const maxWidth = isTablet ? 320 : 280;\n\n return Math.min(smallerAxisSize - appBarHeight, maxWidth);\n};\n\nconst GestureHandlerWrapper = GestureHandlerRootView ?? View;\n\nfunction DrawerViewBase({\n state,\n navigation,\n descriptors,\n defaultStatus,\n drawerContent = (props: DrawerContentComponentProps) => (\n <DrawerContent {...props} />\n ),\n detachInactiveScreens = Platform.OS === 'web' ||\n Platform.OS === 'android' ||\n Platform.OS === 'ios',\n // Running in chrome debugger\n // @ts-expect-error\n useLegacyImplementation = !global.nativeCallSyncHook ||\n // Reanimated 2 is not configured\n // @ts-expect-error: the type definitions are incomplete\n !Animated.isConfigured?.(),\n}: Props) {\n const Drawer: React.ComponentType<DrawerProps> = useLegacyImplementation\n ? require('./legacy/Drawer').default\n : require('./modern/Drawer').default;\n\n const focusedRouteKey = state.routes[state.index].key;\n const {\n drawerHideStatusBarOnOpen = false,\n drawerPosition = I18nManager.isRTL ? 'right' : 'left',\n drawerStatusBarAnimation = 'slide',\n drawerStyle,\n drawerType = Platform.select({ ios: 'slide', default: 'front' }),\n gestureHandlerProps,\n keyboardDismissMode = 'on-drag',\n overlayColor = 'rgba(0, 0, 0, 0.5)',\n swipeEdgeWidth = 32,\n swipeEnabled = Platform.OS !== 'web' &&\n Platform.OS !== 'windows' &&\n Platform.OS !== 'macos',\n swipeMinDistance = 60,\n } = descriptors[focusedRouteKey].options;\n\n const [loaded, setLoaded] = React.useState([focusedRouteKey]);\n\n if (!loaded.includes(focusedRouteKey)) {\n setLoaded([...loaded, focusedRouteKey]);\n }\n\n const dimensions = useSafeAreaFrame();\n\n const { colors } = useTheme();\n\n const drawerStatus = getDrawerStatusFromState(state);\n\n const handleDrawerOpen = React.useCallback(() => {\n navigation.dispatch({\n ...DrawerActions.openDrawer(),\n target: state.key,\n });\n }, [navigation, state.key]);\n\n const handleDrawerClose = React.useCallback(() => {\n navigation.dispatch({\n ...DrawerActions.closeDrawer(),\n target: state.key,\n });\n }, [navigation, state.key]);\n\n React.useEffect(() => {\n if (drawerStatus === defaultStatus || drawerType === 'permanent') {\n return;\n }\n\n const handleHardwareBack = () => {\n // We shouldn't handle the back button if the parent screen isn't focused\n // This will avoid the drawer overriding event listeners from a focused screen\n if (!navigation.isFocused()) {\n return false;\n }\n\n if (defaultStatus === 'open') {\n handleDrawerOpen();\n } else {\n handleDrawerClose();\n }\n\n return true;\n };\n\n const handleEscape = (e: KeyboardEvent) => {\n if (e.key === 'Escape') {\n handleHardwareBack();\n }\n };\n\n // We only add the listeners when drawer opens\n // This way we can make sure that the listener is added as late as possible\n // This will make sure that our handler will run first when back button is pressed\n const subscription = BackHandler.addEventListener(\n 'hardwareBackPress',\n handleHardwareBack\n );\n\n if (Platform.OS === 'web') {\n document?.body?.addEventListener?.('keyup', handleEscape);\n }\n\n return () => {\n subscription.remove();\n\n if (Platform.OS === 'web') {\n document?.body?.removeEventListener?.('keyup', handleEscape);\n }\n };\n }, [\n defaultStatus,\n drawerStatus,\n drawerType,\n handleDrawerClose,\n handleDrawerOpen,\n navigation,\n ]);\n\n const renderDrawerContent = () => {\n return (\n <DrawerPositionContext.Provider value={drawerPosition}>\n {drawerContent({\n state: state,\n navigation: navigation,\n descriptors: descriptors,\n })}\n </DrawerPositionContext.Provider>\n );\n };\n\n const renderSceneContent = () => {\n return (\n <MaybeScreenContainer\n enabled={detachInactiveScreens}\n hasTwoStates\n style={styles.content}\n >\n {state.routes.map((route, index) => {\n const descriptor = descriptors[route.key];\n const { lazy = true, unmountOnBlur } = descriptor.options;\n const isFocused = state.index === index;\n\n if (unmountOnBlur && !isFocused) {\n return null;\n }\n\n if (lazy && !loaded.includes(route.key) && !isFocused) {\n // Don't render a lazy screen if we've never navigated to it\n return null;\n }\n\n const {\n header = ({ layout, options }: DrawerHeaderProps) => (\n <Header\n {...options}\n layout={layout}\n title={getHeaderTitle(options, route.name)}\n headerLeft={\n options.headerLeft ??\n ((props) => <DrawerToggleButton {...props} />)\n }\n />\n ),\n sceneContainerStyle,\n } = descriptor.options;\n\n return (\n <MaybeScreen\n key={route.key}\n style={[StyleSheet.absoluteFill, { zIndex: isFocused ? 0 : -1 }]}\n visible={isFocused}\n enabled={detachInactiveScreens}\n >\n <Screen\n focused={isFocused}\n route={descriptor.route}\n navigation={descriptor.navigation}\n headerShown={descriptor.options.headerShown}\n headerTransparent={descriptor.options.headerTransparent}\n headerStatusBarHeight={descriptor.options.headerStatusBarHeight}\n header={header({\n layout: dimensions,\n route: descriptor.route,\n navigation:\n descriptor.navigation as DrawerNavigationProp<ParamListBase>,\n options: descriptor.options,\n })}\n style={sceneContainerStyle}\n >\n {descriptor.render()}\n </Screen>\n </MaybeScreen>\n );\n })}\n </MaybeScreenContainer>\n );\n };\n\n return (\n <DrawerStatusContext.Provider value={drawerStatus}>\n <Drawer\n open={drawerStatus !== 'closed'}\n onOpen={handleDrawerOpen}\n onClose={handleDrawerClose}\n gestureHandlerProps={gestureHandlerProps}\n swipeEnabled={swipeEnabled}\n swipeEdgeWidth={swipeEdgeWidth}\n swipeVelocityThreshold={500}\n swipeDistanceThreshold={swipeMinDistance}\n hideStatusBarOnOpen={drawerHideStatusBarOnOpen}\n statusBarAnimation={drawerStatusBarAnimation}\n keyboardDismissMode={keyboardDismissMode}\n drawerType={drawerType}\n drawerPosition={drawerPosition}\n drawerStyle={[\n {\n width: getDefaultDrawerWidth(dimensions),\n backgroundColor: colors.card,\n },\n drawerType === 'permanent' &&\n (drawerPosition === 'left'\n ? {\n borderRightColor: colors.border,\n borderRightWidth: StyleSheet.hairlineWidth,\n }\n : {\n borderLeftColor: colors.border,\n borderLeftWidth: StyleSheet.hairlineWidth,\n }),\n drawerStyle,\n ]}\n overlayStyle={{ backgroundColor: overlayColor }}\n renderDrawerContent={renderDrawerContent}\n renderSceneContent={renderSceneContent}\n dimensions={dimensions}\n />\n </DrawerStatusContext.Provider>\n );\n}\n\nexport default function DrawerView({ navigation, ...rest }: Props) {\n return (\n <SafeAreaProviderCompat>\n <GestureHandlerWrapper style={styles.content}>\n <DrawerViewBase navigation={navigation} {...rest} />\n </GestureHandlerWrapper>\n </SafeAreaProviderCompat>\n );\n}\n\nconst styles = StyleSheet.create({\n content: {\n flex: 1,\n },\n});\n"]}
1
+ {"version":3,"sources":["DrawerView.tsx"],"names":["getDefaultDrawerWidth","height","width","smallerAxisSize","Math","min","isLandscape","isTablet","appBarHeight","Platform","OS","maxWidth","GestureHandlerWrapper","GestureHandlerRootView","View","DrawerViewBase","state","navigation","descriptors","defaultStatus","drawerContent","props","detachInactiveScreens","useLegacyImplementation","global","nativeCallSyncHook","Reanimated","isConfigured","Drawer","require","default","focusedRouteKey","routes","index","key","drawerHideStatusBarOnOpen","drawerPosition","I18nManager","isRTL","drawerStatusBarAnimation","drawerStyle","drawerType","select","ios","gestureHandlerProps","keyboardDismissMode","overlayColor","swipeEdgeWidth","swipeEnabled","swipeMinDistance","options","loaded","setLoaded","React","useState","includes","dimensions","colors","drawerStatus","handleDrawerOpen","useCallback","dispatch","DrawerActions","openDrawer","target","handleDrawerClose","closeDrawer","useEffect","handleHardwareBack","isFocused","handleEscape","e","subscription","BackHandler","addEventListener","document","body","remove","removeEventListener","renderDrawerContent","renderSceneContent","styles","content","map","route","descriptor","lazy","unmountOnBlur","header","layout","name","headerLeft","sceneContainerStyle","StyleSheet","absoluteFill","zIndex","headerShown","headerTransparent","headerStatusBarHeight","render","backgroundColor","card","borderRightColor","border","borderRightWidth","hairlineWidth","borderLeftColor","borderLeftWidth","DrawerView","rest","create","flex"],"mappings":";;;;;;;AAAA;;AAMA;;AAOA;;AACA;;AAOA;;AACA;;AAWA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AASA,MAAMA,qBAAqB,GAAG,QAMxB;AAAA,MANyB;AAC7BC,IAAAA,MAD6B;AAE7BC,IAAAA;AAF6B,GAMzB;;AACJ;AACF;AACA;AACA;AACA;AACE,QAAMC,eAAe,GAAGC,IAAI,CAACC,GAAL,CAASJ,MAAT,EAAiBC,KAAjB,CAAxB;AACA,QAAMI,WAAW,GAAGJ,KAAK,GAAGD,MAA5B;AACA,QAAMM,QAAQ,GAAGJ,eAAe,IAAI,GAApC;AACA,QAAMK,YAAY,GAAGC,sBAASC,EAAT,KAAgB,KAAhB,GAAyBJ,WAAW,GAAG,EAAH,GAAQ,EAA5C,GAAkD,EAAvE;AACA,QAAMK,QAAQ,GAAGJ,QAAQ,GAAG,GAAH,GAAS,GAAlC;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lB,CAAf","sourcesContent":["import {\n getHeaderTitle,\n Header,\n SafeAreaProviderCompat,\n Screen,\n} from '@react-navigation/elements';\nimport {\n DrawerActions,\n DrawerNavigationState,\n DrawerStatus,\n ParamListBase,\n useTheme,\n} from '@react-navigation/native';\nimport * as React from 'react';\nimport {\n BackHandler,\n I18nManager,\n Platform,\n StyleSheet,\n View,\n} from 'react-native';\nimport * as Reanimated from 'react-native-reanimated';\nimport { useSafeAreaFrame } from 'react-native-safe-area-context';\n\nimport type {\n DrawerContentComponentProps,\n DrawerDescriptorMap,\n DrawerHeaderProps,\n DrawerNavigationConfig,\n DrawerNavigationHelpers,\n DrawerNavigationProp,\n DrawerProps,\n} from '../types';\nimport DrawerPositionContext from '../utils/DrawerPositionContext';\nimport DrawerStatusContext from '../utils/DrawerStatusContext';\nimport getDrawerStatusFromState from '../utils/getDrawerStatusFromState';\nimport DrawerContent from './DrawerContent';\nimport DrawerToggleButton from './DrawerToggleButton';\nimport { GestureHandlerRootView } from './GestureHandler';\nimport { MaybeScreen, MaybeScreenContainer } from './ScreenFallback';\n\ntype Props = DrawerNavigationConfig & {\n defaultStatus: DrawerStatus;\n state: DrawerNavigationState<ParamListBase>;\n navigation: DrawerNavigationHelpers;\n descriptors: DrawerDescriptorMap;\n};\n\nconst getDefaultDrawerWidth = ({\n height,\n width,\n}: {\n height: number;\n width: number;\n}) => {\n /*\n * Default drawer width is screen width - header height\n * with a max width of 280 on mobile and 320 on tablet\n * https://material.io/components/navigation-drawer\n */\n const smallerAxisSize = Math.min(height, width);\n const isLandscape = width > height;\n const isTablet = smallerAxisSize >= 600;\n const appBarHeight = Platform.OS === 'ios' ? (isLandscape ? 32 : 44) : 56;\n const maxWidth = isTablet ? 320 : 280;\n\n return Math.min(smallerAxisSize - appBarHeight, maxWidth);\n};\n\nconst GestureHandlerWrapper = GestureHandlerRootView ?? View;\n\nfunction DrawerViewBase({\n state,\n navigation,\n descriptors,\n defaultStatus,\n drawerContent = (props: DrawerContentComponentProps) => (\n <DrawerContent {...props} />\n ),\n detachInactiveScreens = Platform.OS === 'web' ||\n Platform.OS === 'android' ||\n Platform.OS === 'ios',\n // Running in chrome debugger\n // @ts-expect-error\n useLegacyImplementation = !global.nativeCallSyncHook ||\n // Reanimated 2 is not configured\n // @ts-expect-error: the type definitions are incomplete\n !Reanimated.isConfigured?.(),\n}: Props) {\n const Drawer: React.ComponentType<DrawerProps> = useLegacyImplementation\n ? require('./legacy/Drawer').default\n : require('./modern/Drawer').default;\n\n const focusedRouteKey = state.routes[state.index].key;\n const {\n drawerHideStatusBarOnOpen = false,\n drawerPosition = I18nManager.isRTL ? 'right' : 'left',\n drawerStatusBarAnimation = 'slide',\n drawerStyle,\n drawerType = Platform.select({ ios: 'slide', default: 'front' }),\n gestureHandlerProps,\n keyboardDismissMode = 'on-drag',\n overlayColor = 'rgba(0, 0, 0, 0.5)',\n swipeEdgeWidth = 32,\n swipeEnabled = Platform.OS !== 'web' &&\n Platform.OS !== 'windows' &&\n Platform.OS !== 'macos',\n swipeMinDistance = 60,\n } = descriptors[focusedRouteKey].options;\n\n const [loaded, setLoaded] = React.useState([focusedRouteKey]);\n\n if (!loaded.includes(focusedRouteKey)) {\n setLoaded([...loaded, focusedRouteKey]);\n }\n\n const dimensions = useSafeAreaFrame();\n\n const { colors } = useTheme();\n\n const drawerStatus = getDrawerStatusFromState(state);\n\n const handleDrawerOpen = React.useCallback(() => {\n navigation.dispatch({\n ...DrawerActions.openDrawer(),\n target: state.key,\n });\n }, [navigation, state.key]);\n\n const handleDrawerClose = React.useCallback(() => {\n navigation.dispatch({\n ...DrawerActions.closeDrawer(),\n target: state.key,\n });\n }, [navigation, state.key]);\n\n React.useEffect(() => {\n if (drawerStatus === defaultStatus || drawerType === 'permanent') {\n return;\n }\n\n const handleHardwareBack = () => {\n // We shouldn't handle the back button if the parent screen isn't focused\n // This will avoid the drawer overriding event listeners from a focused screen\n if (!navigation.isFocused()) {\n return false;\n }\n\n if (defaultStatus === 'open') {\n handleDrawerOpen();\n } else {\n handleDrawerClose();\n }\n\n return true;\n };\n\n const handleEscape = (e: KeyboardEvent) => {\n if (e.key === 'Escape') {\n handleHardwareBack();\n }\n };\n\n // We only add the listeners when drawer opens\n // This way we can make sure that the listener is added as late as possible\n // This will make sure that our handler will run first when back button is pressed\n const subscription = BackHandler.addEventListener(\n 'hardwareBackPress',\n handleHardwareBack\n );\n\n if (Platform.OS === 'web') {\n document?.body?.addEventListener?.('keyup', handleEscape);\n }\n\n return () => {\n subscription.remove();\n\n if (Platform.OS === 'web') {\n document?.body?.removeEventListener?.('keyup', handleEscape);\n }\n };\n }, [\n defaultStatus,\n drawerStatus,\n drawerType,\n handleDrawerClose,\n handleDrawerOpen,\n navigation,\n ]);\n\n const renderDrawerContent = () => {\n return (\n <DrawerPositionContext.Provider value={drawerPosition}>\n {drawerContent({\n state: state,\n navigation: navigation,\n descriptors: descriptors,\n })}\n </DrawerPositionContext.Provider>\n );\n };\n\n const renderSceneContent = () => {\n return (\n <MaybeScreenContainer\n enabled={detachInactiveScreens}\n hasTwoStates\n style={styles.content}\n >\n {state.routes.map((route, index) => {\n const descriptor = descriptors[route.key];\n const { lazy = true, unmountOnBlur } = descriptor.options;\n const isFocused = state.index === index;\n\n if (unmountOnBlur && !isFocused) {\n return null;\n }\n\n if (lazy && !loaded.includes(route.key) && !isFocused) {\n // Don't render a lazy screen if we've never navigated to it\n return null;\n }\n\n const {\n header = ({ layout, options }: DrawerHeaderProps) => (\n <Header\n {...options}\n layout={layout}\n title={getHeaderTitle(options, route.name)}\n headerLeft={\n options.headerLeft ??\n ((props) => <DrawerToggleButton {...props} />)\n }\n />\n ),\n sceneContainerStyle,\n } = descriptor.options;\n\n return (\n <MaybeScreen\n key={route.key}\n style={[StyleSheet.absoluteFill, { zIndex: isFocused ? 0 : -1 }]}\n visible={isFocused}\n enabled={detachInactiveScreens}\n >\n <Screen\n focused={isFocused}\n route={descriptor.route}\n navigation={descriptor.navigation}\n headerShown={descriptor.options.headerShown}\n headerTransparent={descriptor.options.headerTransparent}\n headerStatusBarHeight={descriptor.options.headerStatusBarHeight}\n header={header({\n layout: dimensions,\n route: descriptor.route,\n navigation:\n descriptor.navigation as DrawerNavigationProp<ParamListBase>,\n options: descriptor.options,\n })}\n style={sceneContainerStyle}\n >\n {descriptor.render()}\n </Screen>\n </MaybeScreen>\n );\n })}\n </MaybeScreenContainer>\n );\n };\n\n return (\n <DrawerStatusContext.Provider value={drawerStatus}>\n <Drawer\n open={drawerStatus !== 'closed'}\n onOpen={handleDrawerOpen}\n onClose={handleDrawerClose}\n gestureHandlerProps={gestureHandlerProps}\n swipeEnabled={swipeEnabled}\n swipeEdgeWidth={swipeEdgeWidth}\n swipeVelocityThreshold={500}\n swipeDistanceThreshold={swipeMinDistance}\n hideStatusBarOnOpen={drawerHideStatusBarOnOpen}\n statusBarAnimation={drawerStatusBarAnimation}\n keyboardDismissMode={keyboardDismissMode}\n drawerType={drawerType}\n drawerPosition={drawerPosition}\n drawerStyle={[\n {\n width: getDefaultDrawerWidth(dimensions),\n backgroundColor: colors.card,\n },\n drawerType === 'permanent' &&\n (drawerPosition === 'left'\n ? {\n borderRightColor: colors.border,\n borderRightWidth: StyleSheet.hairlineWidth,\n }\n : {\n borderLeftColor: colors.border,\n borderLeftWidth: StyleSheet.hairlineWidth,\n }),\n drawerStyle,\n ]}\n overlayStyle={{ backgroundColor: overlayColor }}\n renderDrawerContent={renderDrawerContent}\n renderSceneContent={renderSceneContent}\n dimensions={dimensions}\n />\n </DrawerStatusContext.Provider>\n );\n}\n\nexport default function DrawerView({ navigation, ...rest }: Props) {\n return (\n <SafeAreaProviderCompat>\n <GestureHandlerWrapper style={styles.content}>\n <DrawerViewBase navigation={navigation} {...rest} />\n </GestureHandlerWrapper>\n </SafeAreaProviderCompat>\n );\n}\n\nconst styles = StyleSheet.create({\n content: {\n flex: 1,\n },\n});\n"]}
@@ -4,7 +4,7 @@ import { getHeaderTitle, Header, SafeAreaProviderCompat, Screen } from '@react-n
4
4
  import { DrawerActions, useTheme } from '@react-navigation/native';
5
5
  import * as React from 'react';
6
6
  import { BackHandler, I18nManager, Platform, StyleSheet, View } from 'react-native';
7
- import Animated from 'react-native-reanimated';
7
+ import * as Reanimated from 'react-native-reanimated';
8
8
  import { useSafeAreaFrame } from 'react-native-safe-area-context';
9
9
  import DrawerPositionContext from '../utils/DrawerPositionContext';
10
10
  import DrawerStatusContext from '../utils/DrawerStatusContext';
@@ -36,7 +36,7 @@ const getDefaultDrawerWidth = _ref => {
36
36
  const GestureHandlerWrapper = GestureHandlerRootView !== null && GestureHandlerRootView !== void 0 ? GestureHandlerRootView : View;
37
37
 
38
38
  function DrawerViewBase(_ref2) {
39
- var _Animated$isConfigure;
39
+ var _Reanimated$isConfigu;
40
40
 
41
41
  let {
42
42
  state,
@@ -49,7 +49,7 @@ function DrawerViewBase(_ref2) {
49
49
  // @ts-expect-error
50
50
  useLegacyImplementation = !global.nativeCallSyncHook || // Reanimated 2 is not configured
51
51
  // @ts-expect-error: the type definitions are incomplete
52
- !((_Animated$isConfigure = Animated.isConfigured) !== null && _Animated$isConfigure !== void 0 && _Animated$isConfigure.call(Animated))
52
+ !((_Reanimated$isConfigu = Reanimated.isConfigured) !== null && _Reanimated$isConfigu !== void 0 && _Reanimated$isConfigu.call(Reanimated))
53
53
  } = _ref2;
54
54
  const Drawer = useLegacyImplementation ? require('./legacy/Drawer').default : require('./modern/Drawer').default;
55
55
  const focusedRouteKey = state.routes[state.index].key;
@@ -1 +1 @@
1
- {"version":3,"sources":["DrawerView.tsx"],"names":["getHeaderTitle","Header","SafeAreaProviderCompat","Screen","DrawerActions","useTheme","React","BackHandler","I18nManager","Platform","StyleSheet","View","Animated","useSafeAreaFrame","DrawerPositionContext","DrawerStatusContext","getDrawerStatusFromState","DrawerContent","DrawerToggleButton","GestureHandlerRootView","MaybeScreen","MaybeScreenContainer","getDefaultDrawerWidth","height","width","smallerAxisSize","Math","min","isLandscape","isTablet","appBarHeight","OS","maxWidth","GestureHandlerWrapper","DrawerViewBase","state","navigation","descriptors","defaultStatus","drawerContent","props","detachInactiveScreens","useLegacyImplementation","global","nativeCallSyncHook","isConfigured","Drawer","require","default","focusedRouteKey","routes","index","key","drawerHideStatusBarOnOpen","drawerPosition","isRTL","drawerStatusBarAnimation","drawerStyle","drawerType","select","ios","gestureHandlerProps","keyboardDismissMode","overlayColor","swipeEdgeWidth","swipeEnabled","swipeMinDistance","options","loaded","setLoaded","useState","includes","dimensions","colors","drawerStatus","handleDrawerOpen","useCallback","dispatch","openDrawer","target","handleDrawerClose","closeDrawer","useEffect","handleHardwareBack","isFocused","handleEscape","e","subscription","addEventListener","document","body","remove","removeEventListener","renderDrawerContent","renderSceneContent","styles","content","map","route","descriptor","lazy","unmountOnBlur","header","layout","name","headerLeft","sceneContainerStyle","absoluteFill","zIndex","headerShown","headerTransparent","headerStatusBarHeight","render","backgroundColor","card","borderRightColor","border","borderRightWidth","hairlineWidth","borderLeftColor","borderLeftWidth","DrawerView","rest","create","flex"],"mappings":";;AAAA,SACEA,cADF,EAEEC,MAFF,EAGEC,sBAHF,EAIEC,MAJF,QAKO,4BALP;AAMA,SACEC,aADF,EAKEC,QALF,QAMO,0BANP;AAOA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AACA,SACEC,WADF,EAEEC,WAFF,EAGEC,QAHF,EAIEC,UAJF,EAKEC,IALF,QAMO,cANP;AAOA,OAAOC,QAAP,MAAqB,yBAArB;AACA,SAASC,gBAAT,QAAiC,gCAAjC;AAWA,OAAOC,qBAAP,MAAkC,gCAAlC;AACA,OAAOC,mBAAP,MAAgC,8BAAhC;AACA,OAAOC,wBAAP,MAAqC,mCAArC;AACA,OAAOC,aAAP,MAA0B,iBAA1B;AACA,OAAOC,kBAAP,MAA+B,sBAA/B;AACA,SAASC,sBAAT,QAAuC,kBAAvC;AACA,SAASC,WAAT,EAAsBC,oBAAtB,QAAkD,kBAAlD;;AASA,MAAMC,qBAAqB,GAAG,QAMxB;AAAA,MANyB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BE,IAAA,YAAY,EAAE;AAAEwD,MAAAA,eAAe,EAAElD;AAAnB,KA/BhB;AAgCE,IAAA,mBAAmB,EAAE8B,mBAhCvB;AAiCE,IAAA,kBAAkB,EAAEC,kBAjCtB;AAkCE,IAAA,UAAU,EAAEtB;AAlCd,IADF,CADF;AAwCD;;AAED,eAAe,SAASiD,UAAT,QAAoD;AAAA,MAAhC;AAAErF,IAAAA,UAAF;AAAc,OAAGsF;AAAjB,GAAgC;AACjE,sBACE,oBAAC,sBAAD,qBACE,oBAAC,qBAAD;AAAuB,IAAA,KAAK,EAAE3B,MAAM,CAACC;AAArC,kBACE,oBAAC,cAAD;AAAgB,IAAA,UAAU,EAAE5D;AAA5B,KAA4CsF,IAA5C,EADF,CADF,CADF;AAOD;AAED,MAAM3B,MAAM,GAAGrF,UAAU,CAACiH,MAAX,CAAkB;AAC/B3B,EAAAA,OAAO,EAAE;AACP4B,IAAAA,IAAI,EAAE;AADC;AADsB,CAAlB,CAAf","sourcesContent":["import {\n getHeaderTitle,\n Header,\n SafeAreaProviderCompat,\n Screen,\n} from '@react-navigation/elements';\nimport {\n DrawerActions,\n DrawerNavigationState,\n DrawerStatus,\n ParamListBase,\n useTheme,\n} from '@react-navigation/native';\nimport * as React from 'react';\nimport {\n BackHandler,\n I18nManager,\n Platform,\n StyleSheet,\n View,\n} from 'react-native';\nimport Animated from 'react-native-reanimated';\nimport { useSafeAreaFrame } from 'react-native-safe-area-context';\n\nimport type {\n DrawerContentComponentProps,\n DrawerDescriptorMap,\n DrawerHeaderProps,\n DrawerNavigationConfig,\n DrawerNavigationHelpers,\n DrawerNavigationProp,\n DrawerProps,\n} from '../types';\nimport DrawerPositionContext from '../utils/DrawerPositionContext';\nimport DrawerStatusContext from '../utils/DrawerStatusContext';\nimport getDrawerStatusFromState from '../utils/getDrawerStatusFromState';\nimport DrawerContent from './DrawerContent';\nimport DrawerToggleButton from './DrawerToggleButton';\nimport { GestureHandlerRootView } from './GestureHandler';\nimport { MaybeScreen, MaybeScreenContainer } from './ScreenFallback';\n\ntype Props = DrawerNavigationConfig & {\n defaultStatus: DrawerStatus;\n state: DrawerNavigationState<ParamListBase>;\n navigation: DrawerNavigationHelpers;\n descriptors: DrawerDescriptorMap;\n};\n\nconst getDefaultDrawerWidth = ({\n height,\n width,\n}: {\n height: number;\n width: number;\n}) => {\n /*\n * Default drawer width is screen width - header height\n * with a max width of 280 on mobile and 320 on tablet\n * https://material.io/components/navigation-drawer\n */\n const smallerAxisSize = Math.min(height, width);\n const isLandscape = width > height;\n const isTablet = smallerAxisSize >= 600;\n const appBarHeight = Platform.OS === 'ios' ? (isLandscape ? 32 : 44) : 56;\n const maxWidth = isTablet ? 320 : 280;\n\n return Math.min(smallerAxisSize - appBarHeight, maxWidth);\n};\n\nconst GestureHandlerWrapper = GestureHandlerRootView ?? View;\n\nfunction DrawerViewBase({\n state,\n navigation,\n descriptors,\n defaultStatus,\n drawerContent = (props: DrawerContentComponentProps) => (\n <DrawerContent {...props} />\n ),\n detachInactiveScreens = Platform.OS === 'web' ||\n Platform.OS === 'android' ||\n Platform.OS === 'ios',\n // Running in chrome debugger\n // @ts-expect-error\n useLegacyImplementation = !global.nativeCallSyncHook ||\n // Reanimated 2 is not configured\n // @ts-expect-error: the type definitions are incomplete\n !Animated.isConfigured?.(),\n}: Props) {\n const Drawer: React.ComponentType<DrawerProps> = useLegacyImplementation\n ? require('./legacy/Drawer').default\n : require('./modern/Drawer').default;\n\n const focusedRouteKey = state.routes[state.index].key;\n const {\n drawerHideStatusBarOnOpen = false,\n drawerPosition = I18nManager.isRTL ? 'right' : 'left',\n drawerStatusBarAnimation = 'slide',\n drawerStyle,\n drawerType = Platform.select({ ios: 'slide', default: 'front' }),\n gestureHandlerProps,\n keyboardDismissMode = 'on-drag',\n overlayColor = 'rgba(0, 0, 0, 0.5)',\n swipeEdgeWidth = 32,\n swipeEnabled = Platform.OS !== 'web' &&\n Platform.OS !== 'windows' &&\n Platform.OS !== 'macos',\n swipeMinDistance = 60,\n } = descriptors[focusedRouteKey].options;\n\n const [loaded, setLoaded] = React.useState([focusedRouteKey]);\n\n if (!loaded.includes(focusedRouteKey)) {\n setLoaded([...loaded, focusedRouteKey]);\n }\n\n const dimensions = useSafeAreaFrame();\n\n const { colors } = useTheme();\n\n const drawerStatus = getDrawerStatusFromState(state);\n\n const handleDrawerOpen = React.useCallback(() => {\n navigation.dispatch({\n ...DrawerActions.openDrawer(),\n target: state.key,\n });\n }, [navigation, state.key]);\n\n const handleDrawerClose = React.useCallback(() => {\n navigation.dispatch({\n ...DrawerActions.closeDrawer(),\n target: state.key,\n });\n }, [navigation, state.key]);\n\n React.useEffect(() => {\n if (drawerStatus === defaultStatus || drawerType === 'permanent') {\n return;\n }\n\n const handleHardwareBack = () => {\n // We shouldn't handle the back button if the parent screen isn't focused\n // This will avoid the drawer overriding event listeners from a focused screen\n if (!navigation.isFocused()) {\n return false;\n }\n\n if (defaultStatus === 'open') {\n handleDrawerOpen();\n } else {\n handleDrawerClose();\n }\n\n return true;\n };\n\n const handleEscape = (e: KeyboardEvent) => {\n if (e.key === 'Escape') {\n handleHardwareBack();\n }\n };\n\n // We only add the listeners when drawer opens\n // This way we can make sure that the listener is added as late as possible\n // This will make sure that our handler will run first when back button is pressed\n const subscription = BackHandler.addEventListener(\n 'hardwareBackPress',\n handleHardwareBack\n );\n\n if (Platform.OS === 'web') {\n document?.body?.addEventListener?.('keyup', handleEscape);\n }\n\n return () => {\n subscription.remove();\n\n if (Platform.OS === 'web') {\n document?.body?.removeEventListener?.('keyup', handleEscape);\n }\n };\n }, [\n defaultStatus,\n drawerStatus,\n drawerType,\n handleDrawerClose,\n handleDrawerOpen,\n navigation,\n ]);\n\n const renderDrawerContent = () => {\n return (\n <DrawerPositionContext.Provider value={drawerPosition}>\n {drawerContent({\n state: state,\n navigation: navigation,\n descriptors: descriptors,\n })}\n </DrawerPositionContext.Provider>\n );\n };\n\n const renderSceneContent = () => {\n return (\n <MaybeScreenContainer\n enabled={detachInactiveScreens}\n hasTwoStates\n style={styles.content}\n >\n {state.routes.map((route, index) => {\n const descriptor = descriptors[route.key];\n const { lazy = true, unmountOnBlur } = descriptor.options;\n const isFocused = state.index === index;\n\n if (unmountOnBlur && !isFocused) {\n return null;\n }\n\n if (lazy && !loaded.includes(route.key) && !isFocused) {\n // Don't render a lazy screen if we've never navigated to it\n return null;\n }\n\n const {\n header = ({ layout, options }: DrawerHeaderProps) => (\n <Header\n {...options}\n layout={layout}\n title={getHeaderTitle(options, route.name)}\n headerLeft={\n options.headerLeft ??\n ((props) => <DrawerToggleButton {...props} />)\n }\n />\n ),\n sceneContainerStyle,\n } = descriptor.options;\n\n return (\n <MaybeScreen\n key={route.key}\n style={[StyleSheet.absoluteFill, { zIndex: isFocused ? 0 : -1 }]}\n visible={isFocused}\n enabled={detachInactiveScreens}\n >\n <Screen\n focused={isFocused}\n route={descriptor.route}\n navigation={descriptor.navigation}\n headerShown={descriptor.options.headerShown}\n headerTransparent={descriptor.options.headerTransparent}\n headerStatusBarHeight={descriptor.options.headerStatusBarHeight}\n header={header({\n layout: dimensions,\n route: descriptor.route,\n navigation:\n descriptor.navigation as DrawerNavigationProp<ParamListBase>,\n options: descriptor.options,\n })}\n style={sceneContainerStyle}\n >\n {descriptor.render()}\n </Screen>\n </MaybeScreen>\n );\n })}\n </MaybeScreenContainer>\n );\n };\n\n return (\n <DrawerStatusContext.Provider value={drawerStatus}>\n <Drawer\n open={drawerStatus !== 'closed'}\n onOpen={handleDrawerOpen}\n onClose={handleDrawerClose}\n gestureHandlerProps={gestureHandlerProps}\n swipeEnabled={swipeEnabled}\n swipeEdgeWidth={swipeEdgeWidth}\n swipeVelocityThreshold={500}\n swipeDistanceThreshold={swipeMinDistance}\n hideStatusBarOnOpen={drawerHideStatusBarOnOpen}\n statusBarAnimation={drawerStatusBarAnimation}\n keyboardDismissMode={keyboardDismissMode}\n drawerType={drawerType}\n drawerPosition={drawerPosition}\n drawerStyle={[\n {\n width: getDefaultDrawerWidth(dimensions),\n backgroundColor: colors.card,\n },\n drawerType === 'permanent' &&\n (drawerPosition === 'left'\n ? {\n borderRightColor: colors.border,\n borderRightWidth: StyleSheet.hairlineWidth,\n }\n : {\n borderLeftColor: colors.border,\n borderLeftWidth: StyleSheet.hairlineWidth,\n }),\n drawerStyle,\n ]}\n overlayStyle={{ backgroundColor: overlayColor }}\n renderDrawerContent={renderDrawerContent}\n renderSceneContent={renderSceneContent}\n dimensions={dimensions}\n />\n </DrawerStatusContext.Provider>\n );\n}\n\nexport default function DrawerView({ navigation, ...rest }: Props) {\n return (\n <SafeAreaProviderCompat>\n <GestureHandlerWrapper style={styles.content}>\n <DrawerViewBase navigation={navigation} {...rest} />\n </GestureHandlerWrapper>\n </SafeAreaProviderCompat>\n );\n}\n\nconst styles = StyleSheet.create({\n content: {\n flex: 1,\n },\n});\n"]}
1
+ {"version":3,"sources":["DrawerView.tsx"],"names":["getHeaderTitle","Header","SafeAreaProviderCompat","Screen","DrawerActions","useTheme","React","BackHandler","I18nManager","Platform","StyleSheet","View","Reanimated","useSafeAreaFrame","DrawerPositionContext","DrawerStatusContext","getDrawerStatusFromState","DrawerContent","DrawerToggleButton","GestureHandlerRootView","MaybeScreen","MaybeScreenContainer","getDefaultDrawerWidth","height","width","smallerAxisSize","Math","min","isLandscape","isTablet","appBarHeight","OS","maxWidth","GestureHandlerWrapper","DrawerViewBase","state","navigation","descriptors","defaultStatus","drawerContent","props","detachInactiveScreens","useLegacyImplementation","global","nativeCallSyncHook","isConfigured","Drawer","require","default","focusedRouteKey","routes","index","key","drawerHideStatusBarOnOpen","drawerPosition","isRTL","drawerStatusBarAnimation","drawerStyle","drawerType","select","ios","gestureHandlerProps","keyboardDismissMode","overlayColor","swipeEdgeWidth","swipeEnabled","swipeMinDistance","options","loaded","setLoaded","useState","includes","dimensions","colors","drawerStatus","handleDrawerOpen","useCallback","dispatch","openDrawer","target","handleDrawerClose","closeDrawer","useEffect","handleHardwareBack","isFocused","handleEscape","e","subscription","addEventListener","document","body","remove","removeEventListener","renderDrawerContent","renderSceneContent","styles","content","map","route","descriptor","lazy","unmountOnBlur","header","layout","name","headerLeft","sceneContainerStyle","absoluteFill","zIndex","headerShown","headerTransparent","headerStatusBarHeight","render","backgroundColor","card","borderRightColor","border","borderRightWidth","hairlineWidth","borderLeftColor","borderLeftWidth","DrawerView","rest","create","flex"],"mappings":";;AAAA,SACEA,cADF,EAEEC,MAFF,EAGEC,sBAHF,EAIEC,MAJF,QAKO,4BALP;AAMA,SACEC,aADF,EAKEC,QALF,QAMO,0BANP;AAOA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AACA,SACEC,WADF,EAEEC,WAFF,EAGEC,QAHF,EAIEC,UAJF,EAKEC,IALF,QAMO,cANP;AAOA,OAAO,KAAKC,UAAZ,MAA4B,yBAA5B;AACA,SAASC,gBAAT,QAAiC,gCAAjC;AAWA,OAAOC,qBAAP,MAAkC,gCAAlC;AACA,OAAOC,mBAAP,MAAgC,8BAAhC;AACA,OAAOC,wBAAP,MAAqC,mCAArC;AACA,OAAOC,aAAP,MAA0B,iBAA1B;AACA,OAAOC,kBAAP,MAA+B,sBAA/B;AACA,SAASC,sBAAT,QAAuC,kBAAvC;AACA,SAASC,WAAT,EAAsBC,oBAAtB,QAAkD,kBAAlD;;AASA,MAAMC,qBAAqB,GAAG,QAMxB;AAAA,MANyB;AAC7BC,IAAAA,MAD6B;AAE7BC,IAAAA;AAF6B,GAMzB;;AACJ;AACF;AACA;AACA;AACA;AACE,QAAMC,eAAe,GAAGC,IAAI,CAACC,GAAL,CAASJ,MAAT,EAAiBC,KAAjB,CAAxB;AACA,QAAMI,WAAW,GAAGJ,KAAK,GAAGD,MAA5B;AACA,QAAMM,QAAQ,GAAGJ,eAAe,IAAI,GAApC;AACA,QAAMK,YAAY,GAAGrB,QAAQ,CAACsB,EAAT,KAAgB,KAAhB,GAAyBH,WAAW,GAAG,EAAH,GAAQ,EAA5C,GAAkD,EAAvE;AACA,QAAMI,QAAQ,GA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AAC,cAAD;AAAgB,IAAA,UAAU,EAAE5D;AAA5B,KAA4CsF,IAA5C,EADF,CADF,CADF;AAOD;AAED,MAAM3B,MAAM,GAAGrF,UAAU,CAACiH,MAAX,CAAkB;AAC/B3B,EAAAA,OAAO,EAAE;AACP4B,IAAAA,IAAI,EAAE;AADC;AADsB,CAAlB,CAAf","sourcesContent":["import {\n getHeaderTitle,\n Header,\n SafeAreaProviderCompat,\n Screen,\n} from '@react-navigation/elements';\nimport {\n DrawerActions,\n DrawerNavigationState,\n DrawerStatus,\n ParamListBase,\n useTheme,\n} from '@react-navigation/native';\nimport * as React from 'react';\nimport {\n BackHandler,\n I18nManager,\n Platform,\n StyleSheet,\n View,\n} from 'react-native';\nimport * as Reanimated from 'react-native-reanimated';\nimport { useSafeAreaFrame } from 'react-native-safe-area-context';\n\nimport type {\n DrawerContentComponentProps,\n DrawerDescriptorMap,\n DrawerHeaderProps,\n DrawerNavigationConfig,\n DrawerNavigationHelpers,\n DrawerNavigationProp,\n DrawerProps,\n} from '../types';\nimport DrawerPositionContext from '../utils/DrawerPositionContext';\nimport DrawerStatusContext from '../utils/DrawerStatusContext';\nimport getDrawerStatusFromState from '../utils/getDrawerStatusFromState';\nimport DrawerContent from './DrawerContent';\nimport DrawerToggleButton from './DrawerToggleButton';\nimport { GestureHandlerRootView } from './GestureHandler';\nimport { MaybeScreen, MaybeScreenContainer } from './ScreenFallback';\n\ntype Props = DrawerNavigationConfig & {\n defaultStatus: DrawerStatus;\n state: DrawerNavigationState<ParamListBase>;\n navigation: DrawerNavigationHelpers;\n descriptors: DrawerDescriptorMap;\n};\n\nconst getDefaultDrawerWidth = ({\n height,\n width,\n}: {\n height: number;\n width: number;\n}) => {\n /*\n * Default drawer width is screen width - header height\n * with a max width of 280 on mobile and 320 on tablet\n * https://material.io/components/navigation-drawer\n */\n const smallerAxisSize = Math.min(height, width);\n const isLandscape = width > height;\n const isTablet = smallerAxisSize >= 600;\n const appBarHeight = Platform.OS === 'ios' ? (isLandscape ? 32 : 44) : 56;\n const maxWidth = isTablet ? 320 : 280;\n\n return Math.min(smallerAxisSize - appBarHeight, maxWidth);\n};\n\nconst GestureHandlerWrapper = GestureHandlerRootView ?? View;\n\nfunction DrawerViewBase({\n state,\n navigation,\n descriptors,\n defaultStatus,\n drawerContent = (props: DrawerContentComponentProps) => (\n <DrawerContent {...props} />\n ),\n detachInactiveScreens = Platform.OS === 'web' ||\n Platform.OS === 'android' ||\n Platform.OS === 'ios',\n // Running in chrome debugger\n // @ts-expect-error\n useLegacyImplementation = !global.nativeCallSyncHook ||\n // Reanimated 2 is not configured\n // @ts-expect-error: the type definitions are incomplete\n !Reanimated.isConfigured?.(),\n}: Props) {\n const Drawer: React.ComponentType<DrawerProps> = useLegacyImplementation\n ? require('./legacy/Drawer').default\n : require('./modern/Drawer').default;\n\n const focusedRouteKey = state.routes[state.index].key;\n const {\n drawerHideStatusBarOnOpen = false,\n drawerPosition = I18nManager.isRTL ? 'right' : 'left',\n drawerStatusBarAnimation = 'slide',\n drawerStyle,\n drawerType = Platform.select({ ios: 'slide', default: 'front' }),\n gestureHandlerProps,\n keyboardDismissMode = 'on-drag',\n overlayColor = 'rgba(0, 0, 0, 0.5)',\n swipeEdgeWidth = 32,\n swipeEnabled = Platform.OS !== 'web' &&\n Platform.OS !== 'windows' &&\n Platform.OS !== 'macos',\n swipeMinDistance = 60,\n } = descriptors[focusedRouteKey].options;\n\n const [loaded, setLoaded] = React.useState([focusedRouteKey]);\n\n if (!loaded.includes(focusedRouteKey)) {\n setLoaded([...loaded, focusedRouteKey]);\n }\n\n const dimensions = useSafeAreaFrame();\n\n const { colors } = useTheme();\n\n const drawerStatus = getDrawerStatusFromState(state);\n\n const handleDrawerOpen = React.useCallback(() => {\n navigation.dispatch({\n ...DrawerActions.openDrawer(),\n target: state.key,\n });\n }, [navigation, state.key]);\n\n const handleDrawerClose = React.useCallback(() => {\n navigation.dispatch({\n ...DrawerActions.closeDrawer(),\n target: state.key,\n });\n }, [navigation, state.key]);\n\n React.useEffect(() => {\n if (drawerStatus === defaultStatus || drawerType === 'permanent') {\n return;\n }\n\n const handleHardwareBack = () => {\n // We shouldn't handle the back button if the parent screen isn't focused\n // This will avoid the drawer overriding event listeners from a focused screen\n if (!navigation.isFocused()) {\n return false;\n }\n\n if (defaultStatus === 'open') {\n handleDrawerOpen();\n } else {\n handleDrawerClose();\n }\n\n return true;\n };\n\n const handleEscape = (e: KeyboardEvent) => {\n if (e.key === 'Escape') {\n handleHardwareBack();\n }\n };\n\n // We only add the listeners when drawer opens\n // This way we can make sure that the listener is added as late as possible\n // This will make sure that our handler will run first when back button is pressed\n const subscription = BackHandler.addEventListener(\n 'hardwareBackPress',\n handleHardwareBack\n );\n\n if (Platform.OS === 'web') {\n document?.body?.addEventListener?.('keyup', handleEscape);\n }\n\n return () => {\n subscription.remove();\n\n if (Platform.OS === 'web') {\n document?.body?.removeEventListener?.('keyup', handleEscape);\n }\n };\n }, [\n defaultStatus,\n drawerStatus,\n drawerType,\n handleDrawerClose,\n handleDrawerOpen,\n navigation,\n ]);\n\n const renderDrawerContent = () => {\n return (\n <DrawerPositionContext.Provider value={drawerPosition}>\n {drawerContent({\n state: state,\n navigation: navigation,\n descriptors: descriptors,\n })}\n </DrawerPositionContext.Provider>\n );\n };\n\n const renderSceneContent = () => {\n return (\n <MaybeScreenContainer\n enabled={detachInactiveScreens}\n hasTwoStates\n style={styles.content}\n >\n {state.routes.map((route, index) => {\n const descriptor = descriptors[route.key];\n const { lazy = true, unmountOnBlur } = descriptor.options;\n const isFocused = state.index === index;\n\n if (unmountOnBlur && !isFocused) {\n return null;\n }\n\n if (lazy && !loaded.includes(route.key) && !isFocused) {\n // Don't render a lazy screen if we've never navigated to it\n return null;\n }\n\n const {\n header = ({ layout, options }: DrawerHeaderProps) => (\n <Header\n {...options}\n layout={layout}\n title={getHeaderTitle(options, route.name)}\n headerLeft={\n options.headerLeft ??\n ((props) => <DrawerToggleButton {...props} />)\n }\n />\n ),\n sceneContainerStyle,\n } = descriptor.options;\n\n return (\n <MaybeScreen\n key={route.key}\n style={[StyleSheet.absoluteFill, { zIndex: isFocused ? 0 : -1 }]}\n visible={isFocused}\n enabled={detachInactiveScreens}\n >\n <Screen\n focused={isFocused}\n route={descriptor.route}\n navigation={descriptor.navigation}\n headerShown={descriptor.options.headerShown}\n headerTransparent={descriptor.options.headerTransparent}\n headerStatusBarHeight={descriptor.options.headerStatusBarHeight}\n header={header({\n layout: dimensions,\n route: descriptor.route,\n navigation:\n descriptor.navigation as DrawerNavigationProp<ParamListBase>,\n options: descriptor.options,\n })}\n style={sceneContainerStyle}\n >\n {descriptor.render()}\n </Screen>\n </MaybeScreen>\n );\n })}\n </MaybeScreenContainer>\n );\n };\n\n return (\n <DrawerStatusContext.Provider value={drawerStatus}>\n <Drawer\n open={drawerStatus !== 'closed'}\n onOpen={handleDrawerOpen}\n onClose={handleDrawerClose}\n gestureHandlerProps={gestureHandlerProps}\n swipeEnabled={swipeEnabled}\n swipeEdgeWidth={swipeEdgeWidth}\n swipeVelocityThreshold={500}\n swipeDistanceThreshold={swipeMinDistance}\n hideStatusBarOnOpen={drawerHideStatusBarOnOpen}\n statusBarAnimation={drawerStatusBarAnimation}\n keyboardDismissMode={keyboardDismissMode}\n drawerType={drawerType}\n drawerPosition={drawerPosition}\n drawerStyle={[\n {\n width: getDefaultDrawerWidth(dimensions),\n backgroundColor: colors.card,\n },\n drawerType === 'permanent' &&\n (drawerPosition === 'left'\n ? {\n borderRightColor: colors.border,\n borderRightWidth: StyleSheet.hairlineWidth,\n }\n : {\n borderLeftColor: colors.border,\n borderLeftWidth: StyleSheet.hairlineWidth,\n }),\n drawerStyle,\n ]}\n overlayStyle={{ backgroundColor: overlayColor }}\n renderDrawerContent={renderDrawerContent}\n renderSceneContent={renderSceneContent}\n dimensions={dimensions}\n />\n </DrawerStatusContext.Provider>\n );\n}\n\nexport default function DrawerView({ navigation, ...rest }: Props) {\n return (\n <SafeAreaProviderCompat>\n <GestureHandlerWrapper style={styles.content}>\n <DrawerViewBase navigation={navigation} {...rest} />\n </GestureHandlerWrapper>\n </SafeAreaProviderCompat>\n );\n}\n\nconst styles = StyleSheet.create({\n content: {\n flex: 1,\n },\n});\n"]}
@@ -6,7 +6,7 @@ declare const Overlay: React.ForwardRefExoticComponent<{
6
6
  onLayout?: ((event: import("react-native").LayoutChangeEvent) => void) | Animated.Node<((event: import("react-native").LayoutChangeEvent) => void) | undefined> | undefined;
7
7
  pointerEvents?: "none" | "auto" | "box-none" | "box-only" | Animated.Node<"none" | "auto" | "box-none" | "box-only" | undefined> | undefined;
8
8
  removeClippedSubviews?: boolean | Animated.Node<boolean | undefined> | undefined;
9
- style?: import("react-native").StyleProp<Animated.AnimateStyle<import("react-native").StyleProp<import("react-native").ViewStyle>>>;
9
+ style?: import("react-native").StyleProp<import("react-native").ViewStyle> | Animated.Node<import("react-native").StyleProp<import("react-native").ViewStyle>>;
10
10
  testID?: string | Animated.Node<string | undefined> | undefined;
11
11
  nativeID?: string | Animated.Node<string | undefined> | undefined;
12
12
  collapsable?: boolean | Animated.Node<boolean | undefined> | undefined;
@@ -60,6 +60,8 @@ declare const Overlay: React.ForwardRefExoticComponent<{
60
60
  onAccessibilityTap?: (() => void) | Animated.Node<(() => void) | undefined> | undefined;
61
61
  onMagicTap?: (() => void) | Animated.Node<(() => void) | undefined> | undefined;
62
62
  accessibilityIgnoresInvertColors?: boolean | Animated.Node<boolean | undefined> | undefined;
63
+ } & {
64
+ style?: import("react-native").StyleProp<Animated.AnimateStyle<import("react-native").StyleProp<import("react-native").ViewStyle>>>;
63
65
  } & {
64
66
  animatedProps?: Partial<Animated.AnimateProps<import("react-native").ViewProps>> | undefined;
65
67
  layout?: import("react-native-reanimated").BaseAnimationBuilder | import("react-native-reanimated").LayoutAnimationFunction | typeof import("react-native-reanimated").BaseAnimationBuilder | undefined;
@@ -6,7 +6,7 @@ declare const Overlay: React.ForwardRefExoticComponent<{
6
6
  onLayout?: ((event: import("react-native").LayoutChangeEvent) => void) | Animated.Node<((event: import("react-native").LayoutChangeEvent) => void) | undefined> | undefined;
7
7
  pointerEvents?: "none" | "auto" | "box-none" | "box-only" | Animated.Node<"none" | "auto" | "box-none" | "box-only" | undefined> | undefined;
8
8
  removeClippedSubviews?: boolean | Animated.Node<boolean | undefined> | undefined;
9
- style?: import("react-native").StyleProp<Animated.AnimateStyle<import("react-native").StyleProp<import("react-native").ViewStyle>>>;
9
+ style?: import("react-native").StyleProp<import("react-native").ViewStyle> | Animated.Node<import("react-native").StyleProp<import("react-native").ViewStyle>>;
10
10
  testID?: string | Animated.Node<string | undefined> | undefined;
11
11
  nativeID?: string | Animated.Node<string | undefined> | undefined;
12
12
  collapsable?: boolean | Animated.Node<boolean | undefined> | undefined;
@@ -60,6 +60,8 @@ declare const Overlay: React.ForwardRefExoticComponent<{
60
60
  onAccessibilityTap?: (() => void) | Animated.Node<(() => void) | undefined> | undefined;
61
61
  onMagicTap?: (() => void) | Animated.Node<(() => void) | undefined> | undefined;
62
62
  accessibilityIgnoresInvertColors?: boolean | Animated.Node<boolean | undefined> | undefined;
63
+ } & {
64
+ style?: import("react-native").StyleProp<Animated.AnimateStyle<import("react-native").StyleProp<import("react-native").ViewStyle>>>;
63
65
  } & {
64
66
  animatedProps?: Partial<Animated.AnimateProps<import("react-native").ViewProps>> | undefined;
65
67
  layout?: import("react-native-reanimated").BaseAnimationBuilder | import("react-native-reanimated").LayoutAnimationFunction | typeof import("react-native-reanimated").BaseAnimationBuilder | undefined;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@react-navigation/drawer",
3
3
  "description": "Drawer navigator component with animated transitions and gesturess",
4
- "version": "6.3.0",
4
+ "version": "6.3.1",
5
5
  "keywords": [
6
6
  "react-native-component",
7
7
  "react-component",
@@ -83,5 +83,5 @@
83
83
  ]
84
84
  ]
85
85
  },
86
- "gitHead": "4cddbce150413c15db93897c76b813f436f5186d"
86
+ "gitHead": "e669a8ada4f0b2de0366962b3c78f7c1b101f834"
87
87
  }
@@ -19,7 +19,7 @@ import {
19
19
  StyleSheet,
20
20
  View,
21
21
  } from 'react-native';
22
- import Animated from 'react-native-reanimated';
22
+ import * as Reanimated from 'react-native-reanimated';
23
23
  import { useSafeAreaFrame } from 'react-native-safe-area-context';
24
24
 
25
25
  import type {
@@ -85,7 +85,7 @@ function DrawerViewBase({
85
85
  useLegacyImplementation = !global.nativeCallSyncHook ||
86
86
  // Reanimated 2 is not configured
87
87
  // @ts-expect-error: the type definitions are incomplete
88
- !Animated.isConfigured?.(),
88
+ !Reanimated.isConfigured?.(),
89
89
  }: Props) {
90
90
  const Drawer: React.ComponentType<DrawerProps> = useLegacyImplementation
91
91
  ? require('./legacy/Drawer').default