@react-navigation/drawer 6.1.6 → 6.3.0
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.
- package/lib/commonjs/index.js +14 -14
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/navigators/createDrawerNavigator.js +22 -16
- package/lib/commonjs/navigators/createDrawerNavigator.js.map +1 -1
- package/lib/commonjs/utils/DrawerStatusContext.js.map +1 -1
- package/lib/commonjs/utils/getDrawerStatusFromState.js +2 -2
- package/lib/commonjs/utils/getDrawerStatusFromState.js.map +1 -1
- package/lib/commonjs/utils/useDrawerStatus.js.map +1 -1
- package/lib/commonjs/views/DrawerContent.js +6 -5
- package/lib/commonjs/views/DrawerContent.js.map +1 -1
- package/lib/commonjs/views/DrawerContentScrollView.js +7 -6
- package/lib/commonjs/views/DrawerContentScrollView.js.map +1 -1
- package/lib/commonjs/views/DrawerItem.js +16 -12
- package/lib/commonjs/views/DrawerItem.js.map +1 -1
- package/lib/commonjs/views/DrawerItemList.js +28 -14
- package/lib/commonjs/views/DrawerItemList.js.map +1 -1
- package/lib/commonjs/views/DrawerToggleButton.js +5 -4
- package/lib/commonjs/views/DrawerToggleButton.js.map +1 -1
- package/lib/commonjs/views/DrawerView.js +44 -34
- package/lib/commonjs/views/DrawerView.js.map +1 -1
- package/lib/commonjs/views/GestureHandler.js +7 -4
- package/lib/commonjs/views/GestureHandler.js.map +1 -1
- package/lib/commonjs/views/GestureHandlerNative.js +1 -1
- package/lib/commonjs/views/ScreenFallback.js +13 -9
- package/lib/commonjs/views/ScreenFallback.js.map +1 -1
- package/lib/commonjs/views/legacy/Drawer.js +20 -13
- package/lib/commonjs/views/legacy/Drawer.js.map +1 -1
- package/lib/commonjs/views/legacy/Overlay.js +8 -6
- package/lib/commonjs/views/legacy/Overlay.js.map +1 -1
- package/lib/commonjs/views/modern/Drawer.js +28 -30
- package/lib/commonjs/views/modern/Drawer.js.map +1 -1
- package/lib/commonjs/views/modern/Overlay.js +18 -9
- package/lib/commonjs/views/modern/Overlay.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/navigators/createDrawerNavigator.js +22 -16
- package/lib/module/navigators/createDrawerNavigator.js.map +1 -1
- package/lib/module/utils/DrawerStatusContext.js.map +1 -1
- package/lib/module/utils/getDrawerStatusFromState.js +2 -2
- package/lib/module/utils/getDrawerStatusFromState.js.map +1 -1
- package/lib/module/utils/useDrawerStatus.js.map +1 -1
- package/lib/module/views/DrawerContent.js +6 -5
- package/lib/module/views/DrawerContent.js.map +1 -1
- package/lib/module/views/DrawerContentScrollView.js +7 -6
- package/lib/module/views/DrawerContentScrollView.js.map +1 -1
- package/lib/module/views/DrawerItem.js +16 -12
- package/lib/module/views/DrawerItem.js.map +1 -1
- package/lib/module/views/DrawerItemList.js +28 -14
- package/lib/module/views/DrawerItemList.js.map +1 -1
- package/lib/module/views/DrawerToggleButton.js +5 -4
- package/lib/module/views/DrawerToggleButton.js.map +1 -1
- package/lib/module/views/DrawerView.js +43 -33
- package/lib/module/views/DrawerView.js.map +1 -1
- package/lib/module/views/GestureHandler.js +6 -3
- package/lib/module/views/GestureHandler.js.map +1 -1
- package/lib/module/views/ScreenFallback.js +13 -9
- package/lib/module/views/ScreenFallback.js.map +1 -1
- package/lib/module/views/legacy/Drawer.js +20 -13
- package/lib/module/views/legacy/Drawer.js.map +1 -1
- package/lib/module/views/legacy/Overlay.js +8 -6
- package/lib/module/views/legacy/Overlay.js.map +1 -1
- package/lib/module/views/modern/Drawer.js +28 -30
- package/lib/module/views/modern/Drawer.js.map +1 -1
- package/lib/module/views/modern/Overlay.js +19 -10
- package/lib/module/views/modern/Overlay.js.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -1
- package/lib/typescript/src/navigators/createDrawerNavigator.d.ts +1 -1
- package/lib/typescript/src/types.d.ts +13 -1
- package/lib/typescript/src/utils/DrawerStatusContext.d.ts +2 -1
- package/lib/typescript/src/utils/getDrawerStatusFromState.d.ts +2 -2
- package/lib/typescript/src/utils/useDrawerStatus.d.ts +2 -1
- package/lib/typescript/src/views/DrawerItem.d.ts +4 -0
- package/lib/typescript/src/views/DrawerView.d.ts +2 -1
- package/lib/typescript/src/views/ScreenFallback.d.ts +1 -0
- package/lib/typescript/src/views/legacy/Overlay.d.ts +4 -0
- package/lib/typescript/src/views/modern/Overlay.d.ts +4 -0
- package/package.json +10 -10
- package/src/index.tsx +1 -0
- package/src/navigators/createDrawerNavigator.tsx +22 -14
- package/src/types.tsx +11 -1
- package/src/utils/DrawerStatusContext.tsx +4 -2
- package/src/utils/getDrawerStatusFromState.tsx +4 -3
- package/src/utils/useDrawerStatus.tsx +2 -1
- package/src/views/DrawerItem.tsx +6 -0
- package/src/views/DrawerItemList.tsx +21 -8
- package/src/views/DrawerView.tsx +21 -6
- package/src/views/ScreenFallback.tsx +1 -0
- package/src/views/legacy/Drawer.tsx +21 -9
- package/src/views/legacy/Overlay.tsx +1 -0
- package/src/views/modern/Drawer.tsx +25 -23
- package/src/views/modern/Overlay.tsx +16 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["createDrawerNavigator.tsx"],"names":["createNavigatorFactory","DrawerRouter","useNavigationBuilder","React","warnOnce","DrawerView","DrawerNavigator","initialRouteName","defaultStatus","backBehavior","children","screenListeners","screenOptions","openByDefault","lazy","drawerContentOptions","rest","defaultScreenOptions","Object","assign","drawerPosition","drawerType","swipeEdgeWidth","edgeWidth","drawerHideStatusBarOnOpen","hideStatusBar","keyboardDismissMode","swipeMinDistance","minSwipeDistance","overlayColor","drawerStatusBarAnimation","statusBarAnimation","gestureHandlerProps","keys","forEach","key","undefined","JSON","stringify","state","descriptors","navigation","NavigationContent"],"mappings":";;AAAA,SACEA,sBADF,EAKEC,YALF,
|
|
1
|
+
{"version":3,"sources":["createDrawerNavigator.tsx"],"names":["createNavigatorFactory","DrawerRouter","useNavigationBuilder","React","warnOnce","DrawerView","DrawerNavigator","initialRouteName","defaultStatus","customDefaultStatus","backBehavior","children","screenListeners","screenOptions","restWithDeprecated","openByDefault","lazy","drawerContentOptions","rest","defaultScreenOptions","Object","assign","drawerPosition","drawerType","swipeEdgeWidth","edgeWidth","drawerHideStatusBarOnOpen","hideStatusBar","keyboardDismissMode","swipeMinDistance","minSwipeDistance","overlayColor","drawerStatusBarAnimation","statusBarAnimation","gestureHandlerProps","keys","forEach","key","undefined","JSON","stringify","state","descriptors","navigation","NavigationContent"],"mappings":";;AAAA,SACEA,sBADF,EAKEC,YALF,EASEC,oBATF,QAUO,0BAVP;AAWA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AACA,OAAOC,QAAP,MAAqB,WAArB;AAOA,OAAOC,UAAP,MAAuB,qBAAvB;;AAWA,SAASC,eAAT,OAQU;AAAA,MARe;AACvBC,IAAAA,gBADuB;AAEvBC,IAAAA,aAAa,EAAEC,mBAFQ;AAGvBC,IAAAA,YAHuB;AAIvBC,IAAAA,QAJuB;AAKvBC,IAAAA,eALuB;AAMvBC,IAAAA,aANuB;AAOvB,OAAGC;AAPoB,GAQf;AACR,QAAM;AACJ;AACAC,IAAAA,aAFI;AAGJ;AACAC,IAAAA,IAJI;AAKJ;AACAC,IAAAA,oBANI;AAOJ,OAAGC;AAPC,MAQFJ,kBARJ;AAUA,MAAIK,oBAA6C,GAAG,EAApD;;AAEA,MAAIF,oBAAJ,EAA0B;AACxBG,IAAAA,MAAM,CAACC,MAAP,CAAcF,oBAAd,EAAoC;AAClCG,MAAAA,cAAc,EAAEL,oBAAoB,CAACK,cADH;AAElCC,MAAAA,UAAU,EAAEN,oBAAoB,CAACM,UAFC;AAGlCC,MAAAA,cAAc,EAAEP,oBAAoB,CAACQ,SAHH;AAIlCC,MAAAA,yBAAyB,EAAET,oBAAoB,CAACU,aAJd;AAKlCC,MAAAA,mBAAmB,EAAEX,oBAAoB,CAACW,mBALR;AAMlCC,MAAAA,gBAAgB,EAAEZ,oBAAoB,CAACa,gBANL;AAOlCC,MAAAA,YAAY,EAAEd,oBA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,KAAK,EAAEiC,KAHT;AAIE,IAAA,WAAW,EAAEC,WAJf;AAKE,IAAA,UAAU,EAAEC;AALd,KADF,CADF;AAWD;;AAED,eAAe3C,sBAAsB,CAKnCM,eALmC,CAArC","sourcesContent":["import {\n createNavigatorFactory,\n DefaultNavigatorOptions,\n DrawerActionHelpers,\n DrawerNavigationState,\n DrawerRouter,\n DrawerRouterOptions,\n DrawerStatus,\n ParamListBase,\n useNavigationBuilder,\n} from '@react-navigation/native';\nimport * as React from 'react';\nimport warnOnce from 'warn-once';\n\nimport type {\n DrawerNavigationConfig,\n DrawerNavigationEventMap,\n DrawerNavigationOptions,\n} from '../types';\nimport DrawerView from '../views/DrawerView';\n\ntype Props = DefaultNavigatorOptions<\n ParamListBase,\n DrawerNavigationState<ParamListBase>,\n DrawerNavigationOptions,\n DrawerNavigationEventMap\n> &\n DrawerRouterOptions &\n DrawerNavigationConfig;\n\nfunction DrawerNavigator({\n initialRouteName,\n defaultStatus: customDefaultStatus,\n backBehavior,\n children,\n screenListeners,\n screenOptions,\n ...restWithDeprecated\n}: Props) {\n const {\n // @ts-expect-error: openByDefault is deprecated\n openByDefault,\n // @ts-expect-error: lazy is deprecated\n lazy,\n // @ts-expect-error: drawerContentOptions is deprecated\n drawerContentOptions,\n ...rest\n } = restWithDeprecated;\n\n let defaultScreenOptions: DrawerNavigationOptions = {};\n\n if (drawerContentOptions) {\n Object.assign(defaultScreenOptions, {\n drawerPosition: drawerContentOptions.drawerPosition,\n drawerType: drawerContentOptions.drawerType,\n swipeEdgeWidth: drawerContentOptions.edgeWidth,\n drawerHideStatusBarOnOpen: drawerContentOptions.hideStatusBar,\n keyboardDismissMode: drawerContentOptions.keyboardDismissMode,\n swipeMinDistance: drawerContentOptions.minSwipeDistance,\n overlayColor: drawerContentOptions.overlayColor,\n drawerStatusBarAnimation: drawerContentOptions.statusBarAnimation,\n gestureHandlerProps: drawerContentOptions.gestureHandlerProps,\n });\n\n (\n Object.keys(defaultScreenOptions) as (keyof DrawerNavigationOptions)[]\n ).forEach((key) => {\n if (defaultScreenOptions[key] === undefined) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete defaultScreenOptions[key];\n }\n });\n\n warnOnce(\n drawerContentOptions,\n `Drawer Navigator: 'drawerContentOptions' is deprecated. Migrate the options to 'screenOptions' instead.\\n\\nPlace the following in 'screenOptions' in your code to keep current behavior:\\n\\n${JSON.stringify(\n defaultScreenOptions,\n null,\n 2\n )}\\n\\nSee https://reactnavigation.org/docs/drawer-navigator#options for more details.`\n );\n }\n\n if (typeof lazy === 'boolean') {\n defaultScreenOptions.lazy = lazy;\n\n warnOnce(\n true,\n `Drawer Navigator: 'lazy' in props is deprecated. Move it to 'screenOptions' instead.\\n\\nSee https://reactnavigation.org/docs/drawer-navigator/#lazy for more details.`\n );\n }\n\n if (typeof openByDefault === 'boolean') {\n warnOnce(\n true,\n `Drawer Navigator: 'openByDefault' is deprecated. Use 'defaultStatus' and set it to 'open' or 'closed' instead.\\n\\nSee https://reactnavigation.org/docs/drawer-navigator/#defaultstatus for more details.`\n );\n }\n\n const defaultStatus: DrawerStatus =\n customDefaultStatus !== undefined\n ? customDefaultStatus\n : openByDefault\n ? 'open'\n : 'closed';\n\n const { state, descriptors, navigation, NavigationContent } =\n useNavigationBuilder<\n DrawerNavigationState<ParamListBase>,\n DrawerRouterOptions,\n DrawerActionHelpers<ParamListBase>,\n DrawerNavigationOptions,\n DrawerNavigationEventMap\n >(DrawerRouter, {\n initialRouteName,\n defaultStatus,\n backBehavior,\n children,\n screenListeners,\n screenOptions,\n defaultScreenOptions,\n });\n\n return (\n <NavigationContent>\n <DrawerView\n {...rest}\n defaultStatus={defaultStatus}\n state={state}\n descriptors={descriptors}\n navigation={navigation}\n />\n </NavigationContent>\n );\n}\n\nexport default createNavigatorFactory<\n DrawerNavigationState<ParamListBase>,\n DrawerNavigationOptions,\n DrawerNavigationEventMap,\n typeof DrawerNavigator\n>(DrawerNavigator);\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["DrawerStatusContext.tsx"],"names":["React","DrawerStatusContext","createContext","undefined"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["DrawerStatusContext.tsx"],"names":["React","DrawerStatusContext","createContext","undefined"],"mappings":"AACA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AAEA,MAAMC,mBAAmB,gBAAGD,KAAK,CAACE,aAAN,CAC1BC,SAD0B,CAA5B;AAIA,eAAeF,mBAAf","sourcesContent":["import type { DrawerStatus } from '@react-navigation/native';\nimport * as React from 'react';\n\nconst DrawerStatusContext = React.createContext<DrawerStatus | undefined>(\n undefined\n);\n\nexport default DrawerStatusContext;\n"]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export default function getDrawerStatusFromState(state) {
|
|
2
|
-
var _entry$status;
|
|
2
|
+
var _ref, _entry$status;
|
|
3
3
|
|
|
4
4
|
if (state.history == null) {
|
|
5
5
|
throw new Error("Couldn't find the drawer status in the state object. Is it a valid state object of drawer navigator?");
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
const entry = state.history.find(it => it.type === 'drawer');
|
|
9
|
-
return (_entry$status = entry === null || entry === void 0 ? void 0 : entry.status) !== null && _entry$status !== void 0 ? _entry$status : 'closed';
|
|
9
|
+
return (_ref = (_entry$status = entry === null || entry === void 0 ? void 0 : entry.status) !== null && _entry$status !== void 0 ? _entry$status : state.default) !== null && _ref !== void 0 ? _ref : 'closed';
|
|
10
10
|
}
|
|
11
11
|
//# sourceMappingURL=getDrawerStatusFromState.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["getDrawerStatusFromState.tsx"],"names":["getDrawerStatusFromState","state","history","Error","entry","find","it","type","status"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["getDrawerStatusFromState.tsx"],"names":["getDrawerStatusFromState","state","history","Error","entry","find","it","type","status","default"],"mappings":"AAMA,eAAe,SAASA,wBAAT,CACbC,KADa,EAEC;AAAA;;AACd,MAAIA,KAAK,CAACC,OAAN,IAAiB,IAArB,EAA2B;AACzB,UAAM,IAAIC,KAAJ,CACJ,sGADI,CAAN;AAGD;;AAED,QAAMC,KAAK,GAAGH,KAAK,CAACC,OAAN,CAAcG,IAAd,CAAoBC,EAAD,IAAQA,EAAE,CAACC,IAAH,KAAY,QAAvC,CAAd;AAIA,kCAAOH,KAAP,aAAOA,KAAP,uBAAOA,KAAK,CAAEI,MAAd,yDAAwBP,KAAK,CAACQ,OAA9B,uCAAyC,QAAzC;AACD","sourcesContent":["import type {\n DrawerNavigationState,\n DrawerStatus,\n ParamListBase,\n} from '@react-navigation/native';\n\nexport default function getDrawerStatusFromState(\n state: DrawerNavigationState<ParamListBase>\n): DrawerStatus {\n if (state.history == null) {\n throw new Error(\n \"Couldn't find the drawer status in the state object. Is it a valid state object of drawer navigator?\"\n );\n }\n\n const entry = state.history.find((it) => it.type === 'drawer') as\n | { type: 'drawer'; status: DrawerStatus }\n | undefined;\n\n return entry?.status ?? state.default ?? 'closed';\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useDrawerStatus.tsx"],"names":["React","DrawerStatusContext","useDrawerStatus","drawerStatus","useContext","undefined","Error"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["useDrawerStatus.tsx"],"names":["React","DrawerStatusContext","useDrawerStatus","drawerStatus","useContext","undefined","Error"],"mappings":"AACA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AAEA,OAAOC,mBAAP,MAAgC,uBAAhC;AAEA;AACA;AACA;AACA;;AACA,eAAe,SAASC,eAAT,GAAyC;AACtD,QAAMC,YAAY,GAAGH,KAAK,CAACI,UAAN,CAAiBH,mBAAjB,CAArB;;AAEA,MAAIE,YAAY,KAAKE,SAArB,EAAgC;AAC9B,UAAM,IAAIC,KAAJ,CACJ,sEADI,CAAN;AAGD;;AAED,SAAOH,YAAP;AACD","sourcesContent":["import type { DrawerStatus } from '@react-navigation/native';\nimport * as React from 'react';\n\nimport DrawerStatusContext from './DrawerStatusContext';\n\n/**\n * Hook to detect if the drawer's status in a parent navigator.\n * Returns 'open' if the drawer is open, 'closed' if the drawer is closed.\n */\nexport default function useDrawerStatus(): DrawerStatus {\n const drawerStatus = React.useContext(DrawerStatusContext);\n\n if (drawerStatus === undefined) {\n throw new Error(\n \"Couldn't find a drawer. Is your component inside a drawer navigator?\"\n );\n }\n\n return drawerStatus;\n}\n"]}
|
|
@@ -3,11 +3,12 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import DrawerContentScrollView from './DrawerContentScrollView';
|
|
5
5
|
import DrawerItemList from './DrawerItemList';
|
|
6
|
-
export default function DrawerContent({
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
export default function DrawerContent(_ref) {
|
|
7
|
+
let {
|
|
8
|
+
descriptors,
|
|
9
|
+
state,
|
|
10
|
+
...rest
|
|
11
|
+
} = _ref;
|
|
11
12
|
const focusedRoute = state.routes[state.index];
|
|
12
13
|
const focusedDescriptor = descriptors[focusedRoute.key];
|
|
13
14
|
const focusedOptions = focusedDescriptor.options;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["DrawerContent.tsx"],"names":["React","DrawerContentScrollView","DrawerItemList","DrawerContent","descriptors","state","rest","focusedRoute","routes","index","focusedDescriptor","key","focusedOptions","options","drawerContentStyle","drawerContentContainerStyle"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AAGA,OAAOC,uBAAP,MAAoC,2BAApC;AACA,OAAOC,cAAP,MAA2B,kBAA3B;AAEA,eAAe,SAASC,aAAT,
|
|
1
|
+
{"version":3,"sources":["DrawerContent.tsx"],"names":["React","DrawerContentScrollView","DrawerItemList","DrawerContent","descriptors","state","rest","focusedRoute","routes","index","focusedDescriptor","key","focusedOptions","options","drawerContentStyle","drawerContentContainerStyle"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AAGA,OAAOC,uBAAP,MAAoC,2BAApC;AACA,OAAOC,cAAP,MAA2B,kBAA3B;AAEA,eAAe,SAASC,aAAT,OAIiB;AAAA,MAJM;AACpCC,IAAAA,WADoC;AAEpCC,IAAAA,KAFoC;AAGpC,OAAGC;AAHiC,GAIN;AAC9B,QAAMC,YAAY,GAAGF,KAAK,CAACG,MAAN,CAAaH,KAAK,CAACI,KAAnB,CAArB;AACA,QAAMC,iBAAiB,GAAGN,WAAW,CAACG,YAAY,CAACI,GAAd,CAArC;AACA,QAAMC,cAAc,GAAGF,iBAAiB,CAACG,OAAzC;AAEA,QAAM;AAAEC,IAAAA,kBAAF;AAAsBC,IAAAA;AAAtB,MAAsDH,cAA5D;AAEA,sBACE,oBAAC,uBAAD,eACMN,IADN;AAEE,IAAA,qBAAqB,EAAES,2BAFzB;AAGE,IAAA,KAAK,EAAED;AAHT,mBAKE,oBAAC,cAAD;AAAgB,IAAA,WAAW,EAAEV,WAA7B;AAA0C,IAAA,KAAK,EAAEC;AAAjD,KAA4DC,IAA5D,EALF,CADF;AASD","sourcesContent":["import * as React from 'react';\n\nimport type { DrawerContentComponentProps } from '../types';\nimport DrawerContentScrollView from './DrawerContentScrollView';\nimport DrawerItemList from './DrawerItemList';\n\nexport default function DrawerContent({\n descriptors,\n state,\n ...rest\n}: DrawerContentComponentProps) {\n const focusedRoute = state.routes[state.index];\n const focusedDescriptor = descriptors[focusedRoute.key];\n const focusedOptions = focusedDescriptor.options;\n\n const { drawerContentStyle, drawerContentContainerStyle } = focusedOptions;\n\n return (\n <DrawerContentScrollView\n {...rest}\n contentContainerStyle={drawerContentContainerStyle}\n style={drawerContentStyle}\n >\n <DrawerItemList descriptors={descriptors} state={state} {...rest} />\n </DrawerContentScrollView>\n );\n}\n"]}
|
|
@@ -5,12 +5,13 @@ import { I18nManager, ScrollView, StyleSheet } from 'react-native';
|
|
|
5
5
|
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
6
6
|
import DrawerPositionContext from '../utils/DrawerPositionContext';
|
|
7
7
|
|
|
8
|
-
function DrawerContentScrollView({
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
function DrawerContentScrollView(_ref, ref) {
|
|
9
|
+
let {
|
|
10
|
+
contentContainerStyle,
|
|
11
|
+
style,
|
|
12
|
+
children,
|
|
13
|
+
...rest
|
|
14
|
+
} = _ref;
|
|
14
15
|
const drawerPosition = React.useContext(DrawerPositionContext);
|
|
15
16
|
const insets = useSafeAreaInsets();
|
|
16
17
|
const isRight = I18nManager.isRTL ? drawerPosition === 'left' : drawerPosition === 'right';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["DrawerContentScrollView.tsx"],"names":["React","I18nManager","ScrollView","StyleSheet","useSafeAreaInsets","DrawerPositionContext","DrawerContentScrollView","contentContainerStyle","style","children","rest","
|
|
1
|
+
{"version":3,"sources":["DrawerContentScrollView.tsx"],"names":["React","I18nManager","ScrollView","StyleSheet","useSafeAreaInsets","DrawerPositionContext","DrawerContentScrollView","ref","contentContainerStyle","style","children","rest","drawerPosition","useContext","insets","isRight","isRTL","paddingTop","top","paddingStart","left","paddingEnd","right","styles","container","forwardRef","create","flex"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SACEC,WADF,EAEEC,UAFF,EAIEC,UAJF,QAKO,cALP;AAMA,SAASC,iBAAT,QAAkC,gCAAlC;AAEA,OAAOC,qBAAP,MAAkC,gCAAlC;;AAMA,SAASC,uBAAT,OAEEC,GAFF,EAGE;AAAA,MAFA;AAAEC,IAAAA,qBAAF;AAAyBC,IAAAA,KAAzB;AAAgCC,IAAAA,QAAhC;AAA0C,OAAGC;AAA7C,GAEA;AACA,QAAMC,cAAc,GAAGZ,KAAK,CAACa,UAAN,CAAiBR,qBAAjB,CAAvB;AACA,QAAMS,MAAM,GAAGV,iBAAiB,EAAhC;AAEA,QAAMW,OAAO,GAAGd,WAAW,CAACe,KAAZ,GACZJ,cAAc,KAAK,MADP,GAEZA,cAAc,KAAK,OAFvB;AAIA,sBACE,oBAAC,UAAD,eACMD,IADN;AAEE,IAAA,GAAG,EAAEJ,GAFP;AAGE,IAAA,qBAAqB,EAAE,CACrB;AACEU,MAAAA,UAAU,EAAEH,MAAM,CAACI,GAAP,GAAa,CAD3B;AAEEC,MAAAA,YAAY,EAAE,CAACJ,OAAD,GAAWD,MAAM,CAACM,IAAlB,GAAyB,CAFzC;AAGEC,MAAAA,UAAU,EAAEN,OAAO,GAAGD,MAAM,CAACQ,KAAV,GAAkB;AAHvC,KADqB,EAMrBd,qBANqB,CAHzB;AAWE,IAAA,KAAK,EAAE,CAACe,MAAM,CAACC,SAAR,EAAmBf,KAAnB;AAXT,MAaGC,QAbH,CADF;AAiBD;;AAED,4BAAeV,KAAK,CAACyB,UAAN,CAAiBnB,uBAAjB,CAAf;AAEA,MAAMiB,MAAM,GAAGpB,UAAU,CAACuB,MAAX,CAAkB;AAC/BF,EAAAA,SAAS,EAAE;AACTG,IAAAA,IAAI,EAAE;AADG;AADoB,CAAlB,CAAf","sourcesContent":["import * as React from 'react';\nimport {\n I18nManager,\n ScrollView,\n ScrollViewProps,\n StyleSheet,\n} from 'react-native';\nimport { useSafeAreaInsets } from 'react-native-safe-area-context';\n\nimport DrawerPositionContext from '../utils/DrawerPositionContext';\n\ntype Props = ScrollViewProps & {\n children: React.ReactNode;\n};\n\nfunction DrawerContentScrollView(\n { contentContainerStyle, style, children, ...rest }: Props,\n ref?: React.Ref<ScrollView>\n) {\n const drawerPosition = React.useContext(DrawerPositionContext);\n const insets = useSafeAreaInsets();\n\n const isRight = I18nManager.isRTL\n ? drawerPosition === 'left'\n : drawerPosition === 'right';\n\n return (\n <ScrollView\n {...rest}\n ref={ref}\n contentContainerStyle={[\n {\n paddingTop: insets.top + 4,\n paddingStart: !isRight ? insets.left : 0,\n paddingEnd: isRight ? insets.right : 0,\n },\n contentContainerStyle,\n ]}\n style={[styles.container, style]}\n >\n {children}\n </ScrollView>\n );\n}\n\nexport default React.forwardRef(DrawerContentScrollView);\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n },\n});\n"]}
|
|
@@ -6,15 +6,17 @@ import Color from 'color';
|
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import { Platform, StyleSheet, Text, View } from 'react-native';
|
|
8
8
|
|
|
9
|
-
const LinkPressable =
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
const LinkPressable = _ref => {
|
|
10
|
+
let {
|
|
11
|
+
children,
|
|
12
|
+
style,
|
|
13
|
+
onPress,
|
|
14
|
+
onLongPress,
|
|
15
|
+
to,
|
|
16
|
+
accessibilityRole,
|
|
17
|
+
...rest
|
|
18
|
+
} = _ref;
|
|
19
|
+
|
|
18
20
|
if (Platform.OS === 'web' && to) {
|
|
19
21
|
// React Native Web doesn't forward `onClick` if we use `TouchableWithoutFeedback`.
|
|
20
22
|
// We need to use `onClick` to be able to prevent default browser handling of links.
|
|
@@ -25,9 +27,9 @@ const LinkPressable = ({
|
|
|
25
27
|
if (!(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) && ( // ignore clicks with modifier keys
|
|
26
28
|
e.button == null || e.button === 0) // ignore everything but left clicks
|
|
27
29
|
) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
e.preventDefault();
|
|
31
|
+
onPress === null || onPress === void 0 ? void 0 : onPress(e);
|
|
32
|
+
}
|
|
31
33
|
},
|
|
32
34
|
onLongPress: onLongPress !== null && onLongPress !== void 0 ? onLongPress : undefined
|
|
33
35
|
}), children);
|
|
@@ -55,6 +57,7 @@ export default function DrawerItem(props) {
|
|
|
55
57
|
labelStyle,
|
|
56
58
|
to,
|
|
57
59
|
focused = false,
|
|
60
|
+
allowFontScaling,
|
|
58
61
|
activeTintColor = colors.primary,
|
|
59
62
|
inactiveTintColor = Color(colors.text).alpha(0.68).rgb().string(),
|
|
60
63
|
activeBackgroundColor = Color(activeTintColor).alpha(0.12).rgb().string(),
|
|
@@ -101,6 +104,7 @@ export default function DrawerItem(props) {
|
|
|
101
104
|
}]
|
|
102
105
|
}, typeof label === 'string' ? /*#__PURE__*/React.createElement(Text, {
|
|
103
106
|
numberOfLines: 1,
|
|
107
|
+
allowFontScaling: allowFontScaling,
|
|
104
108
|
style: [{
|
|
105
109
|
color,
|
|
106
110
|
fontWeight: '500'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["DrawerItem.tsx"],"names":["PlatformPressable","Link","useTheme","Color","React","Platform","StyleSheet","Text","View","LinkPressable","children","style","onPress","onLongPress","to","accessibilityRole","rest","OS","styles","button","e","metaKey","altKey","ctrlKey","shiftKey","preventDefault","undefined","DrawerItem","props","colors","icon","label","labelStyle","focused","activeTintColor","primary","inactiveTintColor","text","alpha","rgb","string","activeBackgroundColor","inactiveBackgroundColor","pressColor","pressOpacity","borderRadius","flatten","color","backgroundColor","iconNode","size","container","wrapper","selected","marginLeft","marginVertical","fontWeight","create","marginHorizontal","overflow","flexDirection","alignItems","padding","marginRight","flex","display"],"mappings":";;AAAA,SAASA,iBAAT,QAAkC,4BAAlC;AACA,SAASC,IAAT,EAAeC,QAAf,QAA+B,0BAA/B;AACA,OAAOC,KAAP,MAAkB,OAAlB;AACA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AACA,SACEC,QADF,EAGEC,UAHF,EAIEC,IAJF,EAMEC,IANF,QAQO,cARP;;AA6EA,MAAMC,aAAa,GAAG,CAAC;AACrBC,EAAAA,QADqB;AAErBC,EAAAA,KAFqB;AAGrBC,EAAAA,OAHqB;AAIrBC,EAAAA,WAJqB;AAKrBC,EAAAA,EALqB;AAMrBC,EAAAA,iBANqB;AAOrB,KAAGC;AAPkB,CAAD,KAchB;AACJ,MAAIX,QAAQ,CAACY,EAAT,K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EAAEU,UALd;AAME,IAAA,YAAY,EAAEC,YANhB;AAOE,IAAA,EAAE,EAAE9B;AAPN,kBASE,oBAAC,KAAD,CAAO,QAAP,QACGmC,QADH,eAEE,oBAAC,IAAD;AACE,IAAA,KAAK,EAAE,CACL/B,MAAM,CAACa,KADF,EAEL;AAAEuB,MAAAA,UAAU,EAAEL,QAAQ,GAAG,EAAH,GAAQ,CAA9B;AAAiCM,MAAAA,cAAc,EAAE;AAAjD,KAFK;AADT,KAMG,OAAOxB,KAAP,KAAiB,QAAjB,gBACC,oBAAC,IAAD;AACE,IAAA,aAAa,EAAE,CADjB;AAEE,IAAA,KAAK,EAAE,CACL;AACEgB,MAAAA,KADF;AAEES,MAAAA,UAAU,EAAE;AAFd,KADK,EAKLxB,UALK;AAFT,KAUGD,KAVH,CADD,GAcCA,KAAK,CAAC;AAAEgB,IAAAA,KAAF;AAASd,IAAAA;AAAT,GAAD,CApBT,CAFF,CATF,CALF,CADF;AA4CD;AAED,MAAMf,MAAM,GAAGZ,UAAU,CAACmD,MAAX,CAAkB;AAC/BN,EAAAA,SAAS,EAAE;AACTO,IAAAA,gBAAgB,EAAE,EADT;AAETH,IAAAA,cAAc,EAAE,CAFP;AAGTI,IAAAA,QAAQ,EAAE;AAHD,GADoB;AAM/BP,EAAAA,OAAO,EAAE;AACPQ,IAAAA,aAAa,EAAE,KADR;AAEPC,IAAAA,UAAU,EAAE,QAFL;AAGPC,IAAAA,OAAO,EAAE;AAHF,GANsB;AAW/B/B,EAAAA,KAAK,EAAE;AACLgC,IAAAA,WAAW,EAAE,EADR;AAELC,IAAAA,IAAI,EAAE;AAFD,GAXwB;AAe/B7C,EAAAA,MAAM,EAAE;AACN8C,IAAAA,OAAO,EAAE;AADH;AAfuB,CAAlB,CAAf","sourcesContent":["import { PlatformPressable } from '@react-navigation/elements';\nimport { Link, useTheme } from '@react-navigation/native';\nimport Color from 'color';\nimport * as React from 'react';\nimport {\n Platform,\n StyleProp,\n StyleSheet,\n Text,\n TextStyle,\n View,\n ViewStyle,\n} from 'react-native';\n\ntype Props = {\n /**\n * The label text of the item.\n */\n label:\n | string\n | ((props: { focused: boolean; color: string }) => React.ReactNode);\n /**\n * Icon to display for the `DrawerItem`.\n */\n icon?: (props: {\n focused: boolean;\n size: number;\n color: string;\n }) => React.ReactNode;\n /**\n * URL to use for the link to the tab.\n */\n to?: string;\n /**\n * Whether to highlight the drawer item as active.\n */\n focused?: boolean;\n /**\n * Function to execute on press.\n */\n onPress: () => void;\n /**\n * Color for the icon and label when the item is active.\n */\n activeTintColor?: string;\n /**\n * Color for the icon and label when the item is inactive.\n */\n inactiveTintColor?: string;\n /**\n * Background color for item when its active.\n */\n activeBackgroundColor?: string;\n /**\n * Background color for item when its inactive.\n */\n inactiveBackgroundColor?: string;\n /**\n * Color of the touchable effect on press.\n * Only supported on Android.\n *\n * @platform android\n */\n pressColor?: string;\n /**\n * Opacity of the touchable effect on press.\n * Only supported on iOS.\n *\n * @platform ios\n */\n pressOpacity?: number;\n /**\n * Style object for the label element.\n */\n labelStyle?: StyleProp<TextStyle>;\n /**\n * Style object for the wrapper element.\n */\n style?: StyleProp<ViewStyle>;\n};\n\nconst LinkPressable = ({\n children,\n style,\n onPress,\n onLongPress,\n to,\n accessibilityRole,\n ...rest\n}: Omit<React.ComponentProps<typeof PlatformPressable>, 'style'> & {\n style: StyleProp<ViewStyle>;\n} & {\n to?: string;\n children: React.ReactNode;\n onPress?: () => void;\n}) => {\n if (Platform.OS === 'web' && to) {\n // React Native Web doesn't forward `onClick` if we use `TouchableWithoutFeedback`.\n // We need to use `onClick` to be able to prevent default browser handling of links.\n return (\n <Link\n {...rest}\n to={to}\n style={[styles.button, style]}\n onPress={(e: any) => {\n if (\n !(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) && // ignore clicks with modifier keys\n (e.button == null || e.button === 0) // ignore everything but left clicks\n ) {\n e.preventDefault();\n onPress?.(e);\n }\n }}\n onLongPress={onLongPress ?? undefined}\n >\n {children}\n </Link>\n );\n } else {\n return (\n <PlatformPressable\n {...rest}\n accessibilityRole={accessibilityRole}\n onPress={onPress}\n >\n <View style={style}>{children}</View>\n </PlatformPressable>\n );\n }\n};\n\n/**\n * A component used to show an action item with an icon and a label in a navigation drawer.\n */\nexport default function DrawerItem(props: Props) {\n const { colors } = useTheme();\n\n const {\n icon,\n label,\n labelStyle,\n to,\n focused = false,\n activeTintColor = colors.primary,\n inactiveTintColor = Color(colors.text).alpha(0.68).rgb().string(),\n activeBackgroundColor = Color(activeTintColor).alpha(0.12).rgb().string(),\n inactiveBackgroundColor = 'transparent',\n style,\n onPress,\n pressColor,\n pressOpacity,\n ...rest\n } = props;\n\n const { borderRadius = 4 } = StyleSheet.flatten(style || {});\n const color = focused ? activeTintColor : inactiveTintColor;\n const backgroundColor = focused\n ? activeBackgroundColor\n : inactiveBackgroundColor;\n\n const iconNode = icon ? icon({ size: 24, focused, color }) : null;\n\n return (\n <View\n collapsable={false}\n {...rest}\n style={[styles.container, { borderRadius, backgroundColor }, style]}\n >\n <LinkPressable\n onPress={onPress}\n style={[styles.wrapper, { borderRadius }]}\n accessibilityRole=\"button\"\n accessibilityState={{ selected: focused }}\n pressColor={pressColor}\n pressOpacity={pressOpacity}\n to={to}\n >\n <React.Fragment>\n {iconNode}\n <View\n style={[\n styles.label,\n { marginLeft: iconNode ? 32 : 0, marginVertical: 5 },\n ]}\n >\n {typeof label === 'string' ? (\n <Text\n numberOfLines={1}\n style={[\n {\n color,\n fontWeight: '500',\n },\n labelStyle,\n ]}\n >\n {label}\n </Text>\n ) : (\n label({ color, focused })\n )}\n </View>\n </React.Fragment>\n </LinkPressable>\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n marginHorizontal: 10,\n marginVertical: 4,\n overflow: 'hidden',\n },\n wrapper: {\n flexDirection: 'row',\n alignItems: 'center',\n padding: 8,\n },\n label: {\n marginRight: 32,\n flex: 1,\n },\n button: {\n display: 'flex',\n },\n});\n"]}
|
|
1
|
+
{"version":3,"sources":["DrawerItem.tsx"],"names":["PlatformPressable","Link","useTheme","Color","React","Platform","StyleSheet","Text","View","LinkPressable","children","style","onPress","onLongPress","to","accessibilityRole","rest","OS","styles","button","e","metaKey","altKey","ctrlKey","shiftKey","preventDefault","undefined","DrawerItem","props","colors","icon","label","labelStyle","focused","allowFontScaling","activeTintColor","primary","inactiveTintColor","text","alpha","rgb","string","activeBackgroundColor","inactiveBackgroundColor","pressColor","pressOpacity","borderRadius","flatten","color","backgroundColor","iconNode","size","container","wrapper","selected","marginLeft","marginVertical","fontWeight","create","marginHorizontal","overflow","flexDirection","alignItems","padding","marginRight","flex","display"],"mappings":";;AAAA,SAASA,iBAAT,QAAkC,4BAAlC;AACA,SAASC,IAAT,EAAeC,QAAf,QAA+B,0BAA/B;AACA,OAAOC,KAAP,MAAkB,OAAlB;AACA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AACA,SACEC,QADF,EAGEC,UAHF,EAIEC,IAJF,EAMEC,IANF,QAQO,cARP;;AAiFA,MAAMC,aAAa,GAAG,QAchB;AAAA,MAdiB;AACrBC,IAAAA,QADqB;AAErBC,IAAAA,KAFqB;AAGrBC,IAAAA,OAHqB;AAIrBC,IAAAA,WAJqB;AAKrBC,IAAAA,EALqB;AAMrBC,IAAAA,iBANqB;AAOrB,OAAGC;AAPkB,GAcjB;;AACJ,MAAIX,QAAQ,CAACY,EAAT,KAAgB,KAAhB,IAAyBH,EAA7B,EAAiC;AAC/B;AACA;AACA,wBACE,oBAAC,IAAD,eACME,IADN;AAEE,MAAA,EAAE,EAAEF,EAFN;AAGE,MAAA,KAAK,EAAE,CAACI,MAAM,CAACC,MAAR,EAAgBR,KAAhB,CAHT;AAIE,MAAA,OAAO,EAAGS,CAAD,IAAY;AACnB,YACE,EAAEA,CAAC,CAACC,OAAF,IAAaD,CAAC,CAACE,MAAf,IAAyBF,CAAC,CAACG,OAA3B,IAAsCH,CAAC,CAACI,QAA1C,OAAuD;AACtDJ,QAAAA,CAAC,CAAC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;AACE,IAAA,aAAa,EAAE,CADjB;AAEE,IAAA,gBAAgB,EAAEG,gBAFpB;AAGE,IAAA,KAAK,EAAE,CACL;AACEc,MAAAA,KADF;AAEES,MAAAA,UAAU,EAAE;AAFd,KADK,EAKLzB,UALK;AAHT,KAWGD,KAXH,CADD,GAeCA,KAAK,CAAC;AAAEiB,IAAAA,KAAF;AAASf,IAAAA;AAAT,GAAD,CArBT,CAFF,CATF,CALF,CADF;AA6CD;AAED,MAAMf,MAAM,GAAGZ,UAAU,CAACoD,MAAX,CAAkB;AAC/BN,EAAAA,SAAS,EAAE;AACTO,IAAAA,gBAAgB,EAAE,EADT;AAETH,IAAAA,cAAc,EAAE,CAFP;AAGTI,IAAAA,QAAQ,EAAE;AAHD,GADoB;AAM/BP,EAAAA,OAAO,EAAE;AACPQ,IAAAA,aAAa,EAAE,KADR;AAEPC,IAAAA,UAAU,EAAE,QAFL;AAGPC,IAAAA,OAAO,EAAE;AAHF,GANsB;AAW/BhC,EAAAA,KAAK,EAAE;AACLiC,IAAAA,WAAW,EAAE,EADR;AAELC,IAAAA,IAAI,EAAE;AAFD,GAXwB;AAe/B9C,EAAAA,MAAM,EAAE;AACN+C,IAAAA,OAAO,EAAE;AADH;AAfuB,CAAlB,CAAf","sourcesContent":["import { PlatformPressable } from '@react-navigation/elements';\nimport { Link, useTheme } from '@react-navigation/native';\nimport Color from 'color';\nimport * as React from 'react';\nimport {\n Platform,\n StyleProp,\n StyleSheet,\n Text,\n TextStyle,\n View,\n ViewStyle,\n} from 'react-native';\n\ntype Props = {\n /**\n * The label text of the item.\n */\n label:\n | string\n | ((props: { focused: boolean; color: string }) => React.ReactNode);\n /**\n * Icon to display for the `DrawerItem`.\n */\n icon?: (props: {\n focused: boolean;\n size: number;\n color: string;\n }) => React.ReactNode;\n /**\n * URL to use for the link to the tab.\n */\n to?: string;\n /**\n * Whether to highlight the drawer item as active.\n */\n focused?: boolean;\n /**\n * Function to execute on press.\n */\n onPress: () => void;\n /**\n * Color for the icon and label when the item is active.\n */\n activeTintColor?: string;\n /**\n * Color for the icon and label when the item is inactive.\n */\n inactiveTintColor?: string;\n /**\n * Background color for item when its active.\n */\n activeBackgroundColor?: string;\n /**\n * Background color for item when its inactive.\n */\n inactiveBackgroundColor?: string;\n /**\n * Color of the touchable effect on press.\n * Only supported on Android.\n *\n * @platform android\n */\n pressColor?: string;\n /**\n * Opacity of the touchable effect on press.\n * Only supported on iOS.\n *\n * @platform ios\n */\n pressOpacity?: number;\n /**\n * Style object for the label element.\n */\n labelStyle?: StyleProp<TextStyle>;\n /**\n * Style object for the wrapper element.\n */\n style?: StyleProp<ViewStyle>;\n /**\n * Whether label font should scale to respect Text Size accessibility settings.\n */\n allowFontScaling?: boolean;\n};\n\nconst LinkPressable = ({\n children,\n style,\n onPress,\n onLongPress,\n to,\n accessibilityRole,\n ...rest\n}: Omit<React.ComponentProps<typeof PlatformPressable>, 'style'> & {\n style: StyleProp<ViewStyle>;\n} & {\n to?: string;\n children: React.ReactNode;\n onPress?: () => void;\n}) => {\n if (Platform.OS === 'web' && to) {\n // React Native Web doesn't forward `onClick` if we use `TouchableWithoutFeedback`.\n // We need to use `onClick` to be able to prevent default browser handling of links.\n return (\n <Link\n {...rest}\n to={to}\n style={[styles.button, style]}\n onPress={(e: any) => {\n if (\n !(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) && // ignore clicks with modifier keys\n (e.button == null || e.button === 0) // ignore everything but left clicks\n ) {\n e.preventDefault();\n onPress?.(e);\n }\n }}\n onLongPress={onLongPress ?? undefined}\n >\n {children}\n </Link>\n );\n } else {\n return (\n <PlatformPressable\n {...rest}\n accessibilityRole={accessibilityRole}\n onPress={onPress}\n >\n <View style={style}>{children}</View>\n </PlatformPressable>\n );\n }\n};\n\n/**\n * A component used to show an action item with an icon and a label in a navigation drawer.\n */\nexport default function DrawerItem(props: Props) {\n const { colors } = useTheme();\n\n const {\n icon,\n label,\n labelStyle,\n to,\n focused = false,\n allowFontScaling,\n activeTintColor = colors.primary,\n inactiveTintColor = Color(colors.text).alpha(0.68).rgb().string(),\n activeBackgroundColor = Color(activeTintColor).alpha(0.12).rgb().string(),\n inactiveBackgroundColor = 'transparent',\n style,\n onPress,\n pressColor,\n pressOpacity,\n ...rest\n } = props;\n\n const { borderRadius = 4 } = StyleSheet.flatten(style || {});\n const color = focused ? activeTintColor : inactiveTintColor;\n const backgroundColor = focused\n ? activeBackgroundColor\n : inactiveBackgroundColor;\n\n const iconNode = icon ? icon({ size: 24, focused, color }) : null;\n\n return (\n <View\n collapsable={false}\n {...rest}\n style={[styles.container, { borderRadius, backgroundColor }, style]}\n >\n <LinkPressable\n onPress={onPress}\n style={[styles.wrapper, { borderRadius }]}\n accessibilityRole=\"button\"\n accessibilityState={{ selected: focused }}\n pressColor={pressColor}\n pressOpacity={pressOpacity}\n to={to}\n >\n <React.Fragment>\n {iconNode}\n <View\n style={[\n styles.label,\n { marginLeft: iconNode ? 32 : 0, marginVertical: 5 },\n ]}\n >\n {typeof label === 'string' ? (\n <Text\n numberOfLines={1}\n allowFontScaling={allowFontScaling}\n style={[\n {\n color,\n fontWeight: '500',\n },\n labelStyle,\n ]}\n >\n {label}\n </Text>\n ) : (\n label({ color, focused })\n )}\n </View>\n </React.Fragment>\n </LinkPressable>\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n marginHorizontal: 10,\n marginVertical: 4,\n overflow: 'hidden',\n },\n wrapper: {\n flexDirection: 'row',\n alignItems: 'center',\n padding: 8,\n },\n label: {\n marginRight: 32,\n flex: 1,\n },\n button: {\n display: 'flex',\n },\n});\n"]}
|
|
@@ -5,11 +5,12 @@ import DrawerItem from './DrawerItem';
|
|
|
5
5
|
/**
|
|
6
6
|
* Component that renders the navigation list in the drawer.
|
|
7
7
|
*/
|
|
8
|
-
export default function DrawerItemList({
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
export default function DrawerItemList(_ref) {
|
|
9
|
+
let {
|
|
10
|
+
state,
|
|
11
|
+
navigation,
|
|
12
|
+
descriptors
|
|
13
|
+
} = _ref;
|
|
13
14
|
const buildLink = useLinkBuilder();
|
|
14
15
|
const focusedRoute = state.routes[state.index];
|
|
15
16
|
const focusedDescriptor = descriptors[focusedRoute.key];
|
|
@@ -22,12 +23,31 @@ export default function DrawerItemList({
|
|
|
22
23
|
} = focusedOptions;
|
|
23
24
|
return state.routes.map((route, i) => {
|
|
24
25
|
const focused = i === state.index;
|
|
26
|
+
|
|
27
|
+
const onPress = () => {
|
|
28
|
+
const event = navigation.emit({
|
|
29
|
+
type: 'drawerItemPress',
|
|
30
|
+
target: route.key,
|
|
31
|
+
canPreventDefault: true
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
if (!event.defaultPrevented) {
|
|
35
|
+
navigation.dispatch({ ...(focused ? DrawerActions.closeDrawer() : CommonActions.navigate({
|
|
36
|
+
name: route.name,
|
|
37
|
+
merge: true
|
|
38
|
+
})),
|
|
39
|
+
target: state.key
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
25
44
|
const {
|
|
26
45
|
title,
|
|
27
46
|
drawerLabel,
|
|
28
47
|
drawerIcon,
|
|
29
48
|
drawerLabelStyle,
|
|
30
|
-
drawerItemStyle
|
|
49
|
+
drawerItemStyle,
|
|
50
|
+
drawerAllowFontScaling
|
|
31
51
|
} = descriptors[route.key].options;
|
|
32
52
|
return /*#__PURE__*/React.createElement(DrawerItem, {
|
|
33
53
|
key: route.key,
|
|
@@ -38,17 +58,11 @@ export default function DrawerItemList({
|
|
|
38
58
|
inactiveTintColor: drawerInactiveTintColor,
|
|
39
59
|
activeBackgroundColor: drawerActiveBackgroundColor,
|
|
40
60
|
inactiveBackgroundColor: drawerInactiveBackgroundColor,
|
|
61
|
+
allowFontScaling: drawerAllowFontScaling,
|
|
41
62
|
labelStyle: drawerLabelStyle,
|
|
42
63
|
style: drawerItemStyle,
|
|
43
64
|
to: buildLink(route.name, route.params),
|
|
44
|
-
onPress:
|
|
45
|
-
navigation.dispatch({ ...(focused ? DrawerActions.closeDrawer() : CommonActions.navigate({
|
|
46
|
-
name: route.name,
|
|
47
|
-
merge: true
|
|
48
|
-
})),
|
|
49
|
-
target: state.key
|
|
50
|
-
});
|
|
51
|
-
}
|
|
65
|
+
onPress: onPress
|
|
52
66
|
});
|
|
53
67
|
});
|
|
54
68
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["DrawerItemList.tsx"],"names":["CommonActions","DrawerActions","useLinkBuilder","React","DrawerItem","DrawerItemList","state","navigation","descriptors","buildLink","focusedRoute","routes","index","focusedDescriptor","key","focusedOptions","options","drawerActiveTintColor","drawerInactiveTintColor","drawerActiveBackgroundColor","drawerInactiveBackgroundColor","map","route","i","focused","
|
|
1
|
+
{"version":3,"sources":["DrawerItemList.tsx"],"names":["CommonActions","DrawerActions","useLinkBuilder","React","DrawerItem","DrawerItemList","state","navigation","descriptors","buildLink","focusedRoute","routes","index","focusedDescriptor","key","focusedOptions","options","drawerActiveTintColor","drawerInactiveTintColor","drawerActiveBackgroundColor","drawerInactiveBackgroundColor","map","route","i","focused","onPress","event","emit","type","target","canPreventDefault","defaultPrevented","dispatch","closeDrawer","navigate","name","merge","title","drawerLabel","drawerIcon","drawerLabelStyle","drawerItemStyle","drawerAllowFontScaling","undefined","params"],"mappings":"AAAA,SACEA,aADF,EAEEC,aAFF,EAKEC,cALF,QAMO,0BANP;AAOA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AAGA,OAAOC,UAAP,MAAuB,cAAvB;;AAQA;AACA;AACA;AACA,eAAe,SAASC,cAAT,OAIL;AAAA,MAJ6B;AACrCC,IAAAA,KADqC;AAErCC,IAAAA,UAFqC;AAGrCC,IAAAA;AAHqC,GAI7B;AACR,QAAMC,SAAS,GAAGP,cAAc,EAAhC;AAEA,QAAMQ,YAAY,GAAGJ,KAAK,CAACK,MAAN,CAAaL,KAAK,CAACM,KAAnB,CAArB;A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B,GACIL,WADJ,GAEID,KAAK,KAAKM,SAAV,GACAN,KADA,GAEAf,KAAK,CAACa,IAPd;AASE,MAAA,IAAI,EAAEI,UATR;AAUE,MAAA,OAAO,EAAEf,OAVX;AAWE,MAAA,eAAe,EAAEP,qBAXnB;AAYE,MAAA,iBAAiB,EAAEC,uBAZrB;AAaE,MAAA,qBAAqB,EAAEC,2BAbzB;AAcE,MAAA,uBAAuB,EAAEC,6BAd3B;AAeE,MAAA,gBAAgB,EAAEsB,sBAfpB;AAgBE,MAAA,UAAU,EAAEF,gBAhBd;AAiBE,MAAA,KAAK,EAAEC,eAjBT;AAkBE,MAAA,EAAE,EAAEhC,SAAS,CAACa,KAAK,CAACa,IAAP,EAAab,KAAK,CAACsB,MAAnB,CAlBf;AAmBE,MAAA,OAAO,EAAEnB;AAnBX,MADF;AAuBD,GApDM,CAAP;AAqDD","sourcesContent":["import {\n CommonActions,\n DrawerActions,\n DrawerNavigationState,\n ParamListBase,\n useLinkBuilder,\n} from '@react-navigation/native';\nimport * as React from 'react';\n\nimport type { DrawerDescriptorMap, DrawerNavigationHelpers } from '../types';\nimport DrawerItem from './DrawerItem';\n\ntype Props = {\n state: DrawerNavigationState<ParamListBase>;\n navigation: DrawerNavigationHelpers;\n descriptors: DrawerDescriptorMap;\n};\n\n/**\n * Component that renders the navigation list in the drawer.\n */\nexport default function DrawerItemList({\n state,\n navigation,\n descriptors,\n}: Props) {\n const buildLink = useLinkBuilder();\n\n const focusedRoute = state.routes[state.index];\n const focusedDescriptor = descriptors[focusedRoute.key];\n const focusedOptions = focusedDescriptor.options;\n\n const {\n drawerActiveTintColor,\n drawerInactiveTintColor,\n drawerActiveBackgroundColor,\n drawerInactiveBackgroundColor,\n } = focusedOptions;\n\n return state.routes.map((route, i) => {\n const focused = i === state.index;\n\n const onPress = () => {\n const event = navigation.emit({\n type: 'drawerItemPress',\n target: route.key,\n canPreventDefault: true,\n });\n\n if (!event.defaultPrevented) {\n navigation.dispatch({\n ...(focused\n ? DrawerActions.closeDrawer()\n : CommonActions.navigate({ name: route.name, merge: true })),\n target: state.key,\n });\n }\n };\n\n const {\n title,\n drawerLabel,\n drawerIcon,\n drawerLabelStyle,\n drawerItemStyle,\n drawerAllowFontScaling,\n } = descriptors[route.key].options;\n\n return (\n <DrawerItem\n key={route.key}\n label={\n drawerLabel !== undefined\n ? drawerLabel\n : title !== undefined\n ? title\n : route.name\n }\n icon={drawerIcon}\n focused={focused}\n activeTintColor={drawerActiveTintColor}\n inactiveTintColor={drawerInactiveTintColor}\n activeBackgroundColor={drawerActiveBackgroundColor}\n inactiveBackgroundColor={drawerInactiveBackgroundColor}\n allowFontScaling={drawerAllowFontScaling}\n labelStyle={drawerLabelStyle}\n style={drawerItemStyle}\n to={buildLink(route.name, route.params)}\n onPress={onPress}\n />\n );\n }) as React.ReactNode as React.ReactElement;\n}\n"]}
|
|
@@ -4,10 +4,11 @@ import { PlatformPressable } from '@react-navigation/elements';
|
|
|
4
4
|
import { DrawerActions, useNavigation } from '@react-navigation/native';
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import { Image, Platform, StyleSheet } from 'react-native';
|
|
7
|
-
export default function DrawerToggleButton({
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
export default function DrawerToggleButton(_ref) {
|
|
8
|
+
let {
|
|
9
|
+
tintColor,
|
|
10
|
+
...rest
|
|
11
|
+
} = _ref;
|
|
11
12
|
const navigation = useNavigation();
|
|
12
13
|
return /*#__PURE__*/React.createElement(PlatformPressable, _extends({}, rest, {
|
|
13
14
|
accessible: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["DrawerToggleButton.tsx"],"names":["PlatformPressable","DrawerActions","useNavigation","React","Image","Platform","StyleSheet","DrawerToggleButton","tintColor","rest","navigation","borderless","dispatch","toggleDrawer","styles","touchable","select","ios","undefined","default","top","right","bottom","left","icon","require","create","height","width","margin","resizeMode","marginHorizontal"],"mappings":";;AAAA,SAASA,iBAAT,QAAkC,4BAAlC;AACA,SACEC,aADF,EAGEC,aAHF,QAIO,0BAJP;AAKA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AACA,SAASC,KAAT,EAAgBC,QAAhB,EAA0BC,UAA1B,QAA4C,cAA5C;AAWA,eAAe,SAASC,kBAAT,
|
|
1
|
+
{"version":3,"sources":["DrawerToggleButton.tsx"],"names":["PlatformPressable","DrawerActions","useNavigation","React","Image","Platform","StyleSheet","DrawerToggleButton","tintColor","rest","navigation","borderless","dispatch","toggleDrawer","styles","touchable","select","ios","undefined","default","top","right","bottom","left","icon","require","create","height","width","margin","resizeMode","marginHorizontal"],"mappings":";;AAAA,SAASA,iBAAT,QAAkC,4BAAlC;AACA,SACEC,aADF,EAGEC,aAHF,QAIO,0BAJP;AAKA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AACA,SAASC,KAAT,EAAgBC,QAAhB,EAA0BC,UAA1B,QAA4C,cAA5C;AAWA,eAAe,SAASC,kBAAT,OAA2D;AAAA,MAA/B;AAAEC,IAAAA,SAAF;AAAa,OAAGC;AAAhB,GAA+B;AACxE,QAAMC,UAAU,GAAGR,aAAa,EAAhC;AAEA,sBACE,oBAAC,iBAAD,eACMO,IADN;AAEE,IAAA,UAAU,MAFZ;AAGE,IAAA,iBAAiB,EAAC,QAHpB;AAIE,IAAA,cAAc,EAAE;AAAEE,MAAAA,UAAU,EAAE;AAAd,KAJlB;AAKE,IAAA,OAAO,EAAE,MAAMD,UAAU,CAACE,QAAX,CAAoBX,aAAa,CAACY,YAAd,EAApB,CALjB;AAME,IAAA,KAAK,EAAEC,MAAM,CAACC,SANhB;AAOE,IAAA,OAAO,EAAEV,QAAQ,CAACW,MAAT,CAAgB;AACvBC,MAAAA,GAAG,EAAEC,SADkB;AAEvBC,MAAAA,OAAO,EAAE;AAAEC,QAAAA,GAAG,EAAE,EAAP;AAAWC,QAAAA,KAAK,EAAE,EAAlB;AAAsBC,QAAAA,MAAM,EAAE,EAA9B;AAAkCC,QAAAA,IAAI,EAAE;AAAxC;AAFc,KAAhB;AAPX,mBAYE,oBAAC,KAAD;AACE,IAAA,KAAK,EAAE,CAACT,MAAM,CAACU,IAAR,EAAchB,SAAS,GAAG;AAAEA,MAAAA;AAAF,KAAH,GAAmB,IAA1C,CADT;AAEE,IAAA,MAAM,EAAEiB,OAAO,CAAC,iCAAD,CAFjB;AAGE,IAAA,YAAY,EAAE;AAHhB,IAZF,CADF;AAoBD;AAED,MAAMX,MAAM,GAAGR,UAAU,CAACoB,MAAX,CAAkB;AAC/BF,EAAAA,IAAI,EAAE;AACJG,IAAAA,MAAM,EAAE,EADJ;AAEJC,IAAAA,KAAK,EAAE,EAFH;AAGJC,IAAAA,MAAM,EAAE,CAHJ;AAIJC,IAAAA,UAAU,EAAE;AAJR,GADyB;AAO/Bf,EAAAA,SAAS,EAAE;AACTgB,IAAAA,gBAAgB,EAAE;AADT;AAPoB,CAAlB,CAAf","sourcesContent":["import { PlatformPressable } from '@react-navigation/elements';\nimport {\n DrawerActions,\n ParamListBase,\n useNavigation,\n} from '@react-navigation/native';\nimport * as React from 'react';\nimport { Image, Platform, StyleSheet } from 'react-native';\n\nimport type { DrawerNavigationProp } from '../types';\n\ntype Props = {\n accessibilityLabel?: string;\n pressColor?: string;\n pressOpacity?: number;\n tintColor?: string;\n};\n\nexport default function DrawerToggleButton({ tintColor, ...rest }: Props) {\n const navigation = useNavigation<DrawerNavigationProp<ParamListBase>>();\n\n return (\n <PlatformPressable\n {...rest}\n accessible\n accessibilityRole=\"button\"\n android_ripple={{ borderless: true }}\n onPress={() => navigation.dispatch(DrawerActions.toggleDrawer())}\n style={styles.touchable}\n hitSlop={Platform.select({\n ios: undefined,\n default: { top: 16, right: 16, bottom: 16, left: 16 },\n })}\n >\n <Image\n style={[styles.icon, tintColor ? { tintColor } : null]}\n source={require('./assets/toggle-drawer-icon.png')}\n fadeDuration={0}\n />\n </PlatformPressable>\n );\n}\n\nconst styles = StyleSheet.create({\n icon: {\n height: 24,\n width: 24,\n margin: 3,\n resizeMode: 'contain',\n },\n touchable: {\n marginHorizontal: 11,\n },\n});\n"]}
|
|
@@ -14,10 +14,12 @@ import DrawerToggleButton from './DrawerToggleButton';
|
|
|
14
14
|
import { GestureHandlerRootView } from './GestureHandler';
|
|
15
15
|
import { MaybeScreen, MaybeScreenContainer } from './ScreenFallback';
|
|
16
16
|
|
|
17
|
-
const getDefaultDrawerWidth =
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
const getDefaultDrawerWidth = _ref => {
|
|
18
|
+
let {
|
|
19
|
+
height,
|
|
20
|
+
width
|
|
21
|
+
} = _ref;
|
|
22
|
+
|
|
21
23
|
/*
|
|
22
24
|
* Default drawer width is screen width - header height
|
|
23
25
|
* with a max width of 280 on mobile and 320 on tablet
|
|
@@ -33,22 +35,22 @@ const getDefaultDrawerWidth = ({
|
|
|
33
35
|
|
|
34
36
|
const GestureHandlerWrapper = GestureHandlerRootView !== null && GestureHandlerRootView !== void 0 ? GestureHandlerRootView : View;
|
|
35
37
|
|
|
36
|
-
function DrawerViewBase({
|
|
37
|
-
|
|
38
|
-
navigation,
|
|
39
|
-
descriptors,
|
|
40
|
-
drawerContent = props => /*#__PURE__*/React.createElement(DrawerContent, props),
|
|
41
|
-
detachInactiveScreens = Platform.OS === 'web' || Platform.OS === 'android' || Platform.OS === 'ios',
|
|
42
|
-
// Running in chrome debugger
|
|
43
|
-
// @ts-expect-error
|
|
44
|
-
useLegacyImplementation = !global.nativeCallSyncHook || // Reanimated 2 is not configured
|
|
45
|
-
// @ts-expect-error: the type definitions are incomplete
|
|
46
|
-
!(() => {
|
|
47
|
-
var _Animated$isConfigure;
|
|
38
|
+
function DrawerViewBase(_ref2) {
|
|
39
|
+
var _Animated$isConfigure;
|
|
48
40
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
41
|
+
let {
|
|
42
|
+
state,
|
|
43
|
+
navigation,
|
|
44
|
+
descriptors,
|
|
45
|
+
defaultStatus,
|
|
46
|
+
drawerContent = props => /*#__PURE__*/React.createElement(DrawerContent, props),
|
|
47
|
+
detachInactiveScreens = Platform.OS === 'web' || Platform.OS === 'android' || Platform.OS === 'ios',
|
|
48
|
+
// Running in chrome debugger
|
|
49
|
+
// @ts-expect-error
|
|
50
|
+
useLegacyImplementation = !global.nativeCallSyncHook || // Reanimated 2 is not configured
|
|
51
|
+
// @ts-expect-error: the type definitions are incomplete
|
|
52
|
+
!((_Animated$isConfigure = Animated.isConfigured) !== null && _Animated$isConfigure !== void 0 && _Animated$isConfigure.call(Animated))
|
|
53
|
+
} = _ref2;
|
|
52
54
|
const Drawer = useLegacyImplementation ? require('./legacy/Drawer').default : require('./modern/Drawer').default;
|
|
53
55
|
const focusedRouteKey = state.routes[state.index].key;
|
|
54
56
|
const {
|
|
@@ -89,31 +91,36 @@ function DrawerViewBase({
|
|
|
89
91
|
});
|
|
90
92
|
}, [navigation, state.key]);
|
|
91
93
|
React.useEffect(() => {
|
|
92
|
-
if (drawerStatus
|
|
94
|
+
if (drawerStatus === defaultStatus || drawerType === 'permanent') {
|
|
93
95
|
return;
|
|
94
96
|
}
|
|
95
97
|
|
|
96
|
-
const
|
|
98
|
+
const handleHardwareBack = () => {
|
|
97
99
|
// We shouldn't handle the back button if the parent screen isn't focused
|
|
98
100
|
// This will avoid the drawer overriding event listeners from a focused screen
|
|
99
101
|
if (!navigation.isFocused()) {
|
|
100
102
|
return false;
|
|
101
103
|
}
|
|
102
104
|
|
|
103
|
-
|
|
105
|
+
if (defaultStatus === 'open') {
|
|
106
|
+
handleDrawerOpen();
|
|
107
|
+
} else {
|
|
108
|
+
handleDrawerClose();
|
|
109
|
+
}
|
|
110
|
+
|
|
104
111
|
return true;
|
|
105
112
|
};
|
|
106
113
|
|
|
107
114
|
const handleEscape = e => {
|
|
108
115
|
if (e.key === 'Escape') {
|
|
109
|
-
|
|
116
|
+
handleHardwareBack();
|
|
110
117
|
}
|
|
111
118
|
}; // We only add the listeners when drawer opens
|
|
112
119
|
// This way we can make sure that the listener is added as late as possible
|
|
113
120
|
// This will make sure that our handler will run first when back button is pressed
|
|
114
121
|
|
|
115
122
|
|
|
116
|
-
const subscription = BackHandler.addEventListener('hardwareBackPress',
|
|
123
|
+
const subscription = BackHandler.addEventListener('hardwareBackPress', handleHardwareBack);
|
|
117
124
|
|
|
118
125
|
if (Platform.OS === 'web') {
|
|
119
126
|
var _document, _document$body, _document$body$addEve;
|
|
@@ -130,7 +137,7 @@ function DrawerViewBase({
|
|
|
130
137
|
(_document2 = document) === null || _document2 === void 0 ? void 0 : (_document2$body = _document2.body) === null || _document2$body === void 0 ? void 0 : (_document2$body$remov = _document2$body.removeEventListener) === null || _document2$body$remov === void 0 ? void 0 : _document2$body$remov.call(_document2$body, 'keyup', handleEscape);
|
|
131
138
|
}
|
|
132
139
|
};
|
|
133
|
-
}, [drawerStatus, drawerType, handleDrawerClose, navigation]);
|
|
140
|
+
}, [defaultStatus, drawerStatus, drawerType, handleDrawerClose, handleDrawerOpen, navigation]);
|
|
134
141
|
|
|
135
142
|
const renderDrawerContent = () => {
|
|
136
143
|
return /*#__PURE__*/React.createElement(DrawerPositionContext.Provider, {
|
|
@@ -145,6 +152,7 @@ function DrawerViewBase({
|
|
|
145
152
|
const renderSceneContent = () => {
|
|
146
153
|
return /*#__PURE__*/React.createElement(MaybeScreenContainer, {
|
|
147
154
|
enabled: detachInactiveScreens,
|
|
155
|
+
hasTwoStates: true,
|
|
148
156
|
style: styles.content
|
|
149
157
|
}, state.routes.map((route, index) => {
|
|
150
158
|
const descriptor = descriptors[route.key];
|
|
@@ -164,12 +172,13 @@ function DrawerViewBase({
|
|
|
164
172
|
}
|
|
165
173
|
|
|
166
174
|
const {
|
|
167
|
-
header =
|
|
168
|
-
layout,
|
|
169
|
-
options
|
|
170
|
-
}) => {
|
|
175
|
+
header = _ref3 => {
|
|
171
176
|
var _options$headerLeft;
|
|
172
177
|
|
|
178
|
+
let {
|
|
179
|
+
layout,
|
|
180
|
+
options
|
|
181
|
+
} = _ref3;
|
|
173
182
|
return /*#__PURE__*/React.createElement(Header, _extends({}, options, {
|
|
174
183
|
layout: layout,
|
|
175
184
|
title: getHeaderTitle(options, route.name),
|
|
@@ -238,10 +247,11 @@ function DrawerViewBase({
|
|
|
238
247
|
}));
|
|
239
248
|
}
|
|
240
249
|
|
|
241
|
-
export default function DrawerView({
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
250
|
+
export default function DrawerView(_ref4) {
|
|
251
|
+
let {
|
|
252
|
+
navigation,
|
|
253
|
+
...rest
|
|
254
|
+
} = _ref4;
|
|
245
255
|
return /*#__PURE__*/React.createElement(SafeAreaProviderCompat, null, /*#__PURE__*/React.createElement(GestureHandlerWrapper, {
|
|
246
256
|
style: styles.content
|
|
247
257
|
}, /*#__PURE__*/React.createElement(DrawerViewBase, _extends({
|