@react-navigation/drawer 6.1.5

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.
Files changed (186) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +5 -0
  3. package/lib/commonjs/index.js +104 -0
  4. package/lib/commonjs/index.js.map +1 -0
  5. package/lib/commonjs/navigators/createDrawerNavigator.js +95 -0
  6. package/lib/commonjs/navigators/createDrawerNavigator.js.map +1 -0
  7. package/lib/commonjs/types.js +6 -0
  8. package/lib/commonjs/types.js.map +1 -0
  9. package/lib/commonjs/utils/DrawerGestureContext.js +17 -0
  10. package/lib/commonjs/utils/DrawerGestureContext.js.map +1 -0
  11. package/lib/commonjs/utils/DrawerPositionContext.js +17 -0
  12. package/lib/commonjs/utils/DrawerPositionContext.js.map +1 -0
  13. package/lib/commonjs/utils/DrawerProgressContext.js +17 -0
  14. package/lib/commonjs/utils/DrawerProgressContext.js.map +1 -0
  15. package/lib/commonjs/utils/DrawerStatusContext.js +17 -0
  16. package/lib/commonjs/utils/DrawerStatusContext.js.map +1 -0
  17. package/lib/commonjs/utils/getDrawerStatusFromState.js +18 -0
  18. package/lib/commonjs/utils/getDrawerStatusFromState.js.map +1 -0
  19. package/lib/commonjs/utils/useDrawerProgress.js +27 -0
  20. package/lib/commonjs/utils/useDrawerProgress.js.map +1 -0
  21. package/lib/commonjs/utils/useDrawerStatus.js +31 -0
  22. package/lib/commonjs/utils/useDrawerStatus.js.map +1 -0
  23. package/lib/commonjs/views/DrawerContent.js +42 -0
  24. package/lib/commonjs/views/DrawerContent.js.map +1 -0
  25. package/lib/commonjs/views/DrawerContentScrollView.js +53 -0
  26. package/lib/commonjs/views/DrawerContentScrollView.js.map +1 -0
  27. package/lib/commonjs/views/DrawerItem.js +152 -0
  28. package/lib/commonjs/views/DrawerItem.js.map +1 -0
  29. package/lib/commonjs/views/DrawerItemList.js +70 -0
  30. package/lib/commonjs/views/DrawerItemList.js.map +1 -0
  31. package/lib/commonjs/views/DrawerToggleButton.js +64 -0
  32. package/lib/commonjs/views/DrawerToggleButton.js.map +1 -0
  33. package/lib/commonjs/views/DrawerView.js +282 -0
  34. package/lib/commonjs/views/DrawerView.js.map +1 -0
  35. package/lib/commonjs/views/GestureHandler.android.js +19 -0
  36. package/lib/commonjs/views/GestureHandler.android.js.map +1 -0
  37. package/lib/commonjs/views/GestureHandler.ios.js +19 -0
  38. package/lib/commonjs/views/GestureHandler.ios.js.map +1 -0
  39. package/lib/commonjs/views/GestureHandler.js +35 -0
  40. package/lib/commonjs/views/GestureHandler.js.map +1 -0
  41. package/lib/commonjs/views/GestureHandlerNative.js +50 -0
  42. package/lib/commonjs/views/GestureHandlerNative.js.map +1 -0
  43. package/lib/commonjs/views/ScreenFallback.js +62 -0
  44. package/lib/commonjs/views/ScreenFallback.js.map +1 -0
  45. package/lib/commonjs/views/assets/toggle-drawer-icon.png +0 -0
  46. package/lib/commonjs/views/assets/toggle-drawer-icon@1.5x.android.png +0 -0
  47. package/lib/commonjs/views/assets/toggle-drawer-icon@1.5x.ios.png +0 -0
  48. package/lib/commonjs/views/assets/toggle-drawer-icon@1x.android.png +0 -0
  49. package/lib/commonjs/views/assets/toggle-drawer-icon@1x.ios.png +0 -0
  50. package/lib/commonjs/views/assets/toggle-drawer-icon@2x.android.png +0 -0
  51. package/lib/commonjs/views/assets/toggle-drawer-icon@2x.ios.png +0 -0
  52. package/lib/commonjs/views/assets/toggle-drawer-icon@3x.android.png +0 -0
  53. package/lib/commonjs/views/assets/toggle-drawer-icon@3x.ios.png +0 -0
  54. package/lib/commonjs/views/assets/toggle-drawer-icon@4x.android.png +0 -0
  55. package/lib/commonjs/views/assets/toggle-drawer-icon@4x.ios.png +0 -0
  56. package/lib/commonjs/views/legacy/Drawer.js +455 -0
  57. package/lib/commonjs/views/legacy/Drawer.js.map +1 -0
  58. package/lib/commonjs/views/legacy/Overlay.js +79 -0
  59. package/lib/commonjs/views/legacy/Overlay.js.map +1 -0
  60. package/lib/commonjs/views/modern/Drawer.js +293 -0
  61. package/lib/commonjs/views/modern/Drawer.js.map +1 -0
  62. package/lib/commonjs/views/modern/Overlay.js +65 -0
  63. package/lib/commonjs/views/modern/Overlay.js.map +1 -0
  64. package/lib/module/index.js +27 -0
  65. package/lib/module/index.js.map +1 -0
  66. package/lib/module/navigators/createDrawerNavigator.js +77 -0
  67. package/lib/module/navigators/createDrawerNavigator.js.map +1 -0
  68. package/lib/module/types.js +2 -0
  69. package/lib/module/types.js.map +1 -0
  70. package/lib/module/utils/DrawerGestureContext.js +3 -0
  71. package/lib/module/utils/DrawerGestureContext.js.map +1 -0
  72. package/lib/module/utils/DrawerPositionContext.js +3 -0
  73. package/lib/module/utils/DrawerPositionContext.js.map +1 -0
  74. package/lib/module/utils/DrawerProgressContext.js +3 -0
  75. package/lib/module/utils/DrawerProgressContext.js.map +1 -0
  76. package/lib/module/utils/DrawerStatusContext.js +4 -0
  77. package/lib/module/utils/DrawerStatusContext.js.map +1 -0
  78. package/lib/module/utils/getDrawerStatusFromState.js +11 -0
  79. package/lib/module/utils/getDrawerStatusFromState.js.map +1 -0
  80. package/lib/module/utils/useDrawerProgress.js +12 -0
  81. package/lib/module/utils/useDrawerProgress.js.map +1 -0
  82. package/lib/module/utils/useDrawerStatus.js +17 -0
  83. package/lib/module/utils/useDrawerStatus.js.map +1 -0
  84. package/lib/module/views/DrawerContent.js +26 -0
  85. package/lib/module/views/DrawerContent.js.map +1 -0
  86. package/lib/module/views/DrawerContentScrollView.js +34 -0
  87. package/lib/module/views/DrawerContentScrollView.js.map +1 -0
  88. package/lib/module/views/DrawerItem.js +132 -0
  89. package/lib/module/views/DrawerItem.js.map +1 -0
  90. package/lib/module/views/DrawerItemList.js +55 -0
  91. package/lib/module/views/DrawerItemList.js.map +1 -0
  92. package/lib/module/views/DrawerToggleButton.js +48 -0
  93. package/lib/module/views/DrawerToggleButton.js.map +1 -0
  94. package/lib/module/views/DrawerView.js +256 -0
  95. package/lib/module/views/DrawerView.js.map +1 -0
  96. package/lib/module/views/GestureHandler.android.js +2 -0
  97. package/lib/module/views/GestureHandler.android.js.map +1 -0
  98. package/lib/module/views/GestureHandler.ios.js +2 -0
  99. package/lib/module/views/GestureHandler.ios.js.map +1 -0
  100. package/lib/module/views/GestureHandler.js +19 -0
  101. package/lib/module/views/GestureHandler.js.map +1 -0
  102. package/lib/module/views/GestureHandlerNative.js +11 -0
  103. package/lib/module/views/GestureHandlerNative.js.map +1 -0
  104. package/lib/module/views/ScreenFallback.js +44 -0
  105. package/lib/module/views/ScreenFallback.js.map +1 -0
  106. package/lib/module/views/assets/toggle-drawer-icon.png +0 -0
  107. package/lib/module/views/assets/toggle-drawer-icon@1.5x.android.png +0 -0
  108. package/lib/module/views/assets/toggle-drawer-icon@1.5x.ios.png +0 -0
  109. package/lib/module/views/assets/toggle-drawer-icon@1x.android.png +0 -0
  110. package/lib/module/views/assets/toggle-drawer-icon@1x.ios.png +0 -0
  111. package/lib/module/views/assets/toggle-drawer-icon@2x.android.png +0 -0
  112. package/lib/module/views/assets/toggle-drawer-icon@2x.ios.png +0 -0
  113. package/lib/module/views/assets/toggle-drawer-icon@3x.android.png +0 -0
  114. package/lib/module/views/assets/toggle-drawer-icon@3x.ios.png +0 -0
  115. package/lib/module/views/assets/toggle-drawer-icon@4x.android.png +0 -0
  116. package/lib/module/views/assets/toggle-drawer-icon@4x.ios.png +0 -0
  117. package/lib/module/views/legacy/Drawer.js +430 -0
  118. package/lib/module/views/legacy/Drawer.js.map +1 -0
  119. package/lib/module/views/legacy/Overlay.js +59 -0
  120. package/lib/module/views/legacy/Overlay.js.map +1 -0
  121. package/lib/module/views/modern/Drawer.js +272 -0
  122. package/lib/module/views/modern/Drawer.js.map +1 -0
  123. package/lib/module/views/modern/Overlay.js +47 -0
  124. package/lib/module/views/modern/Overlay.js.map +1 -0
  125. package/lib/typescript/src/index.d.ts +25 -0
  126. package/lib/typescript/src/navigators/createDrawerNavigator.d.ts +7 -0
  127. package/lib/typescript/src/types.d.ts +235 -0
  128. package/lib/typescript/src/utils/DrawerGestureContext.d.ts +3 -0
  129. package/lib/typescript/src/utils/DrawerPositionContext.d.ts +3 -0
  130. package/lib/typescript/src/utils/DrawerProgressContext.d.ts +4 -0
  131. package/lib/typescript/src/utils/DrawerStatusContext.d.ts +3 -0
  132. package/lib/typescript/src/utils/getDrawerStatusFromState.d.ts +2 -0
  133. package/lib/typescript/src/utils/useDrawerProgress.d.ts +2 -0
  134. package/lib/typescript/src/utils/useDrawerStatus.d.ts +5 -0
  135. package/lib/typescript/src/views/DrawerContent.d.ts +3 -0
  136. package/lib/typescript/src/views/DrawerContentScrollView.d.ts +6 -0
  137. package/lib/typescript/src/views/DrawerItem.d.ts +74 -0
  138. package/lib/typescript/src/views/DrawerItemList.d.ts +13 -0
  139. package/lib/typescript/src/views/DrawerToggleButton.d.ts +9 -0
  140. package/lib/typescript/src/views/DrawerView.d.ts +10 -0
  141. package/lib/typescript/src/views/GestureHandler.android.d.ts +1 -0
  142. package/lib/typescript/src/views/GestureHandler.d.ts +14 -0
  143. package/lib/typescript/src/views/GestureHandler.ios.d.ts +1 -0
  144. package/lib/typescript/src/views/GestureHandlerNative.d.ts +4 -0
  145. package/lib/typescript/src/views/ScreenFallback.d.ts +14 -0
  146. package/lib/typescript/src/views/legacy/Drawer.d.ts +44 -0
  147. package/lib/typescript/src/views/legacy/Overlay.d.ts +68 -0
  148. package/lib/typescript/src/views/modern/Drawer.d.ts +3 -0
  149. package/lib/typescript/src/views/modern/Overlay.d.ts +68 -0
  150. package/package.json +87 -0
  151. package/src/index.tsx +34 -0
  152. package/src/navigators/createDrawerNavigator.tsx +134 -0
  153. package/src/types.tsx +300 -0
  154. package/src/utils/DrawerGestureContext.tsx +3 -0
  155. package/src/utils/DrawerPositionContext.tsx +3 -0
  156. package/src/utils/DrawerProgressContext.tsx +6 -0
  157. package/src/utils/DrawerStatusContext.tsx +6 -0
  158. package/src/utils/getDrawerStatusFromState.tsx +20 -0
  159. package/src/utils/useDrawerProgress.tsx +18 -0
  160. package/src/utils/useDrawerStatus.tsx +19 -0
  161. package/src/views/DrawerContent.tsx +27 -0
  162. package/src/views/DrawerContentScrollView.tsx +52 -0
  163. package/src/views/DrawerItem.tsx +227 -0
  164. package/src/views/DrawerItemList.tsx +80 -0
  165. package/src/views/DrawerToggleButton.tsx +54 -0
  166. package/src/views/DrawerView.tsx +313 -0
  167. package/src/views/GestureHandler.android.tsx +1 -0
  168. package/src/views/GestureHandler.ios.tsx +1 -0
  169. package/src/views/GestureHandler.tsx +29 -0
  170. package/src/views/GestureHandlerNative.tsx +24 -0
  171. package/src/views/ScreenFallback.tsx +48 -0
  172. package/src/views/assets/toggle-drawer-icon.png +0 -0
  173. package/src/views/assets/toggle-drawer-icon@1.5x.android.png +0 -0
  174. package/src/views/assets/toggle-drawer-icon@1.5x.ios.png +0 -0
  175. package/src/views/assets/toggle-drawer-icon@1x.android.png +0 -0
  176. package/src/views/assets/toggle-drawer-icon@1x.ios.png +0 -0
  177. package/src/views/assets/toggle-drawer-icon@2x.android.png +0 -0
  178. package/src/views/assets/toggle-drawer-icon@2x.ios.png +0 -0
  179. package/src/views/assets/toggle-drawer-icon@3x.android.png +0 -0
  180. package/src/views/assets/toggle-drawer-icon@3x.ios.png +0 -0
  181. package/src/views/assets/toggle-drawer-icon@4x.android.png +0 -0
  182. package/src/views/assets/toggle-drawer-icon@4x.ios.png +0 -0
  183. package/src/views/legacy/Drawer.tsx +659 -0
  184. package/src/views/legacy/Overlay.tsx +74 -0
  185. package/src/views/modern/Drawer.tsx +385 -0
  186. package/src/views/modern/Overlay.tsx +56 -0
@@ -0,0 +1,17 @@
1
+ import * as React from 'react';
2
+ import DrawerStatusContext from './DrawerStatusContext';
3
+ /**
4
+ * Hook to detect if the drawer's status in a parent navigator.
5
+ * Returns 'open' if the drawer is open, 'closed' if the drawer is closed.
6
+ */
7
+
8
+ export default function useDrawerStatus() {
9
+ const drawerStatus = React.useContext(DrawerStatusContext);
10
+
11
+ if (drawerStatus === undefined) {
12
+ throw new Error("Couldn't find a drawer. Is your component inside a drawer navigator?");
13
+ }
14
+
15
+ return drawerStatus;
16
+ }
17
+ //# sourceMappingURL=useDrawerStatus.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["useDrawerStatus.tsx"],"names":["React","DrawerStatusContext","useDrawerStatus","drawerStatus","useContext","undefined","Error"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AAEA,OAAOC,mBAAP,MAAgC,uBAAhC;AAEA;AACA;AACA;AACA;;AACA,eAAe,SAASC,eAAT,GAA2B;AACxC,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 * 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() {\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"]}
@@ -0,0 +1,26 @@
1
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+
3
+ import * as React from 'react';
4
+ import DrawerContentScrollView from './DrawerContentScrollView';
5
+ import DrawerItemList from './DrawerItemList';
6
+ export default function DrawerContent({
7
+ descriptors,
8
+ state,
9
+ ...rest
10
+ }) {
11
+ const focusedRoute = state.routes[state.index];
12
+ const focusedDescriptor = descriptors[focusedRoute.key];
13
+ const focusedOptions = focusedDescriptor.options;
14
+ const {
15
+ drawerContentStyle,
16
+ drawerContentContainerStyle
17
+ } = focusedOptions;
18
+ return /*#__PURE__*/React.createElement(DrawerContentScrollView, _extends({}, rest, {
19
+ contentContainerStyle: drawerContentContainerStyle,
20
+ style: drawerContentStyle
21
+ }), /*#__PURE__*/React.createElement(DrawerItemList, _extends({
22
+ descriptors: descriptors,
23
+ state: state
24
+ }, rest)));
25
+ }
26
+ //# sourceMappingURL=DrawerContent.js.map
@@ -0,0 +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,CAAuB;AACpCC,EAAAA,WADoC;AAEpCC,EAAAA,KAFoC;AAGpC,KAAGC;AAHiC,CAAvB,EAIiB;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"]}
@@ -0,0 +1,34 @@
1
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+
3
+ import * as React from 'react';
4
+ import { I18nManager, ScrollView, StyleSheet } from 'react-native';
5
+ import { useSafeAreaInsets } from 'react-native-safe-area-context';
6
+ import DrawerPositionContext from '../utils/DrawerPositionContext';
7
+
8
+ function DrawerContentScrollView({
9
+ contentContainerStyle,
10
+ style,
11
+ children,
12
+ ...rest
13
+ }, ref) {
14
+ const drawerPosition = React.useContext(DrawerPositionContext);
15
+ const insets = useSafeAreaInsets();
16
+ const isRight = I18nManager.isRTL ? drawerPosition === 'left' : drawerPosition === 'right';
17
+ return /*#__PURE__*/React.createElement(ScrollView, _extends({}, rest, {
18
+ ref: ref,
19
+ contentContainerStyle: [{
20
+ paddingTop: insets.top + 4,
21
+ paddingStart: !isRight ? insets.left : 0,
22
+ paddingEnd: isRight ? insets.right : 0
23
+ }, contentContainerStyle],
24
+ style: [styles.container, style]
25
+ }), children);
26
+ }
27
+
28
+ export default /*#__PURE__*/React.forwardRef(DrawerContentScrollView);
29
+ const styles = StyleSheet.create({
30
+ container: {
31
+ flex: 1
32
+ }
33
+ });
34
+ //# sourceMappingURL=DrawerContentScrollView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["DrawerContentScrollView.tsx"],"names":["React","I18nManager","ScrollView","StyleSheet","useSafeAreaInsets","DrawerPositionContext","DrawerContentScrollView","contentContainerStyle","style","children","rest","ref","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,CACE;AAAEC,EAAAA,qBAAF;AAAyBC,EAAAA,KAAzB;AAAgCC,EAAAA,QAAhC;AAA0C,KAAGC;AAA7C,CADF,EAEEC,GAFF,EAGE;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,eACMF,IADN;AAEE,IAAA,GAAG,EAAEC,GAFP;AAGE,IAAA,qBAAqB,EAAE,CACrB;AACEM,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,EAMrBf,qBANqB,CAHzB;AAWE,IAAA,KAAK,EAAE,CAACgB,MAAM,CAACC,SAAR,EAAmBhB,KAAnB;AAXT,MAaGC,QAbH,CADF;AAiBD;;AAED,4BAAeT,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"]}
@@ -0,0 +1,132 @@
1
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+
3
+ import { PlatformPressable } from '@react-navigation/elements';
4
+ import { Link, useTheme } from '@react-navigation/native';
5
+ import Color from 'color';
6
+ import * as React from 'react';
7
+ import { Platform, StyleSheet, Text, View } from 'react-native';
8
+
9
+ const LinkPressable = ({
10
+ children,
11
+ style,
12
+ onPress,
13
+ onLongPress,
14
+ to,
15
+ accessibilityRole,
16
+ ...rest
17
+ }) => {
18
+ if (Platform.OS === 'web' && to) {
19
+ // React Native Web doesn't forward `onClick` if we use `TouchableWithoutFeedback`.
20
+ // We need to use `onClick` to be able to prevent default browser handling of links.
21
+ return /*#__PURE__*/React.createElement(Link, _extends({}, rest, {
22
+ to: to,
23
+ style: [styles.button, style],
24
+ onPress: e => {
25
+ if (!(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) && ( // ignore clicks with modifier keys
26
+ e.button == null || e.button === 0) // ignore everything but left clicks
27
+ ) {
28
+ e.preventDefault();
29
+ onPress === null || onPress === void 0 ? void 0 : onPress(e);
30
+ }
31
+ },
32
+ onLongPress: onLongPress !== null && onLongPress !== void 0 ? onLongPress : undefined
33
+ }), children);
34
+ } else {
35
+ return /*#__PURE__*/React.createElement(PlatformPressable, _extends({}, rest, {
36
+ accessibilityRole: accessibilityRole,
37
+ onPress: onPress
38
+ }), /*#__PURE__*/React.createElement(View, {
39
+ style: style
40
+ }, children));
41
+ }
42
+ };
43
+ /**
44
+ * A component used to show an action item with an icon and a label in a navigation drawer.
45
+ */
46
+
47
+
48
+ export default function DrawerItem(props) {
49
+ const {
50
+ colors
51
+ } = useTheme();
52
+ const {
53
+ icon,
54
+ label,
55
+ labelStyle,
56
+ to,
57
+ focused = false,
58
+ activeTintColor = colors.primary,
59
+ inactiveTintColor = Color(colors.text).alpha(0.68).rgb().string(),
60
+ activeBackgroundColor = Color(activeTintColor).alpha(0.12).rgb().string(),
61
+ inactiveBackgroundColor = 'transparent',
62
+ style,
63
+ onPress,
64
+ pressColor,
65
+ pressOpacity,
66
+ ...rest
67
+ } = props;
68
+ const {
69
+ borderRadius = 4
70
+ } = StyleSheet.flatten(style || {});
71
+ const color = focused ? activeTintColor : inactiveTintColor;
72
+ const backgroundColor = focused ? activeBackgroundColor : inactiveBackgroundColor;
73
+ const iconNode = icon ? icon({
74
+ size: 24,
75
+ focused,
76
+ color
77
+ }) : null;
78
+ return /*#__PURE__*/React.createElement(View, _extends({
79
+ collapsable: false
80
+ }, rest, {
81
+ style: [styles.container, {
82
+ borderRadius,
83
+ backgroundColor
84
+ }, style]
85
+ }), /*#__PURE__*/React.createElement(LinkPressable, {
86
+ onPress: onPress,
87
+ style: [styles.wrapper, {
88
+ borderRadius
89
+ }],
90
+ accessibilityRole: "button",
91
+ accessibilityState: {
92
+ selected: focused
93
+ },
94
+ pressColor: pressColor,
95
+ pressOpacity: pressOpacity,
96
+ to: to
97
+ }, /*#__PURE__*/React.createElement(React.Fragment, null, iconNode, /*#__PURE__*/React.createElement(View, {
98
+ style: [styles.label, {
99
+ marginLeft: iconNode ? 32 : 0,
100
+ marginVertical: 5
101
+ }]
102
+ }, typeof label === 'string' ? /*#__PURE__*/React.createElement(Text, {
103
+ numberOfLines: 1,
104
+ style: [{
105
+ color,
106
+ fontWeight: '500'
107
+ }, labelStyle]
108
+ }, label) : label({
109
+ color,
110
+ focused
111
+ })))));
112
+ }
113
+ const styles = StyleSheet.create({
114
+ container: {
115
+ marginHorizontal: 10,
116
+ marginVertical: 4,
117
+ overflow: 'hidden'
118
+ },
119
+ wrapper: {
120
+ flexDirection: 'row',
121
+ alignItems: 'center',
122
+ padding: 8
123
+ },
124
+ label: {
125
+ marginRight: 32,
126
+ flex: 1
127
+ },
128
+ button: {
129
+ display: 'flex'
130
+ }
131
+ });
132
+ //# sourceMappingURL=DrawerItem.js.map
@@ -0,0 +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,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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"]}
@@ -0,0 +1,55 @@
1
+ import { CommonActions, DrawerActions, useLinkBuilder } from '@react-navigation/native';
2
+ import * as React from 'react';
3
+ import DrawerItem from './DrawerItem';
4
+
5
+ /**
6
+ * Component that renders the navigation list in the drawer.
7
+ */
8
+ export default function DrawerItemList({
9
+ state,
10
+ navigation,
11
+ descriptors
12
+ }) {
13
+ const buildLink = useLinkBuilder();
14
+ const focusedRoute = state.routes[state.index];
15
+ const focusedDescriptor = descriptors[focusedRoute.key];
16
+ const focusedOptions = focusedDescriptor.options;
17
+ const {
18
+ drawerActiveTintColor,
19
+ drawerInactiveTintColor,
20
+ drawerActiveBackgroundColor,
21
+ drawerInactiveBackgroundColor
22
+ } = focusedOptions;
23
+ return state.routes.map((route, i) => {
24
+ const focused = i === state.index;
25
+ const {
26
+ title,
27
+ drawerLabel,
28
+ drawerIcon,
29
+ drawerLabelStyle,
30
+ drawerItemStyle
31
+ } = descriptors[route.key].options;
32
+ return /*#__PURE__*/React.createElement(DrawerItem, {
33
+ key: route.key,
34
+ label: drawerLabel !== undefined ? drawerLabel : title !== undefined ? title : route.name,
35
+ icon: drawerIcon,
36
+ focused: focused,
37
+ activeTintColor: drawerActiveTintColor,
38
+ inactiveTintColor: drawerInactiveTintColor,
39
+ activeBackgroundColor: drawerActiveBackgroundColor,
40
+ inactiveBackgroundColor: drawerInactiveBackgroundColor,
41
+ labelStyle: drawerLabelStyle,
42
+ style: drawerItemStyle,
43
+ 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
+ }
52
+ });
53
+ });
54
+ }
55
+ //# sourceMappingURL=DrawerItemList.js.map
@@ -0,0 +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","title","drawerLabel","drawerIcon","drawerLabelStyle","drawerItemStyle","undefined","name","params","dispatch","closeDrawer","navigate","merge","target"],"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,CAAwB;AACrCC,EAAAA,KADqC;AAErCC,EAAAA,UAFqC;AAGrCC,EAAAA;AAHqC,CAAxB,EAIL;AACR,QAAMC,SAAS,GAAGP,cAAc,EAAhC;AAEA,QAAMQ,YAAY,GAAGJ,KAAK,CAACK,MAAN,CAAaL,KAAK,CAACM,KAAnB,CAArB;AACA,QAAMC,iBAAiB,GAAGL,WAAW,CAACE,YAAY,CAACI,GAAd,CAArC;AACA,QAAMC,cAAc,GAAGF,iBAAiB,CAACG,OAAzC;AAEA,QAAM;AACJC,IAAAA,qBADI;AAEJC,IAAAA,uBAFI;AAGJC,IAAAA,2BAHI;AAIJC,IAAAA;AAJI,MAKFL,cALJ;AAOA,SAAOT,KAAK,CAACK,MAAN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NavigationState,\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 const {\n title,\n drawerLabel,\n drawerIcon,\n drawerLabelStyle,\n drawerItemStyle,\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 labelStyle={drawerLabelStyle}\n style={drawerItemStyle}\n to={buildLink(route.name, route.params)}\n onPress={() => {\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 }) as React.ReactNode as React.ReactElement;\n}\n"]}
@@ -0,0 +1,48 @@
1
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+
3
+ import { PlatformPressable } from '@react-navigation/elements';
4
+ import { DrawerActions, useNavigation } from '@react-navigation/native';
5
+ import * as React from 'react';
6
+ import { Image, Platform, StyleSheet } from 'react-native';
7
+ export default function DrawerToggleButton({
8
+ tintColor,
9
+ ...rest
10
+ }) {
11
+ const navigation = useNavigation();
12
+ return /*#__PURE__*/React.createElement(PlatformPressable, _extends({}, rest, {
13
+ accessible: true,
14
+ accessibilityRole: "button",
15
+ android_ripple: {
16
+ borderless: true
17
+ },
18
+ onPress: () => navigation.dispatch(DrawerActions.toggleDrawer()),
19
+ style: styles.touchable,
20
+ hitSlop: Platform.select({
21
+ ios: undefined,
22
+ default: {
23
+ top: 16,
24
+ right: 16,
25
+ bottom: 16,
26
+ left: 16
27
+ }
28
+ })
29
+ }), /*#__PURE__*/React.createElement(Image, {
30
+ style: [styles.icon, tintColor ? {
31
+ tintColor
32
+ } : null],
33
+ source: require('./assets/toggle-drawer-icon.png'),
34
+ fadeDuration: 0
35
+ }));
36
+ }
37
+ const styles = StyleSheet.create({
38
+ icon: {
39
+ height: 24,
40
+ width: 24,
41
+ margin: 3,
42
+ resizeMode: 'contain'
43
+ },
44
+ touchable: {
45
+ marginHorizontal: 11
46
+ }
47
+ });
48
+ //# sourceMappingURL=DrawerToggleButton.js.map
@@ -0,0 +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,CAA4B;AAAEC,EAAAA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ListBase,\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"]}
@@ -0,0 +1,256 @@
1
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+
3
+ import { getHeaderTitle, Header, SafeAreaProviderCompat, Screen } from '@react-navigation/elements';
4
+ import { DrawerActions, useTheme } from '@react-navigation/native';
5
+ import * as React from 'react';
6
+ import { BackHandler, I18nManager, Platform, StyleSheet, View } from 'react-native';
7
+ import Animated from 'react-native-reanimated';
8
+ import { useSafeAreaFrame } from 'react-native-safe-area-context';
9
+ import DrawerPositionContext from '../utils/DrawerPositionContext';
10
+ import DrawerStatusContext from '../utils/DrawerStatusContext';
11
+ import getDrawerStatusFromState from '../utils/getDrawerStatusFromState';
12
+ import DrawerContent from './DrawerContent';
13
+ import DrawerToggleButton from './DrawerToggleButton';
14
+ import { GestureHandlerRootView } from './GestureHandler';
15
+ import { MaybeScreen, MaybeScreenContainer } from './ScreenFallback';
16
+
17
+ const getDefaultDrawerWidth = ({
18
+ height,
19
+ width
20
+ }) => {
21
+ /*
22
+ * Default drawer width is screen width - header height
23
+ * with a max width of 280 on mobile and 320 on tablet
24
+ * https://material.io/components/navigation-drawer
25
+ */
26
+ const smallerAxisSize = Math.min(height, width);
27
+ const isLandscape = width > height;
28
+ const isTablet = smallerAxisSize >= 600;
29
+ const appBarHeight = Platform.OS === 'ios' ? isLandscape ? 32 : 44 : 56;
30
+ const maxWidth = isTablet ? 320 : 280;
31
+ return Math.min(smallerAxisSize - appBarHeight, maxWidth);
32
+ };
33
+
34
+ const GestureHandlerWrapper = GestureHandlerRootView !== null && GestureHandlerRootView !== void 0 ? GestureHandlerRootView : View;
35
+
36
+ function DrawerViewBase({
37
+ state,
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;
48
+
49
+ return (_Animated$isConfigure = Animated.isConfigured) === null || _Animated$isConfigure === void 0 ? void 0 : _Animated$isConfigure.call(Animated);
50
+ })()
51
+ }) {
52
+ const Drawer = useLegacyImplementation ? require('./legacy/Drawer').default : require('./modern/Drawer').default;
53
+ const focusedRouteKey = state.routes[state.index].key;
54
+ const {
55
+ drawerHideStatusBarOnOpen = false,
56
+ drawerPosition = I18nManager.isRTL ? 'right' : 'left',
57
+ drawerStatusBarAnimation = 'slide',
58
+ drawerStyle,
59
+ drawerType = Platform.select({
60
+ ios: 'slide',
61
+ default: 'front'
62
+ }),
63
+ gestureHandlerProps,
64
+ keyboardDismissMode = 'on-drag',
65
+ overlayColor = 'rgba(0, 0, 0, 0.5)',
66
+ swipeEdgeWidth = 32,
67
+ swipeEnabled = Platform.OS !== 'web' && Platform.OS !== 'windows' && Platform.OS !== 'macos',
68
+ swipeMinDistance = 60
69
+ } = descriptors[focusedRouteKey].options;
70
+ const [loaded, setLoaded] = React.useState([focusedRouteKey]);
71
+
72
+ if (!loaded.includes(focusedRouteKey)) {
73
+ setLoaded([...loaded, focusedRouteKey]);
74
+ }
75
+
76
+ const dimensions = useSafeAreaFrame();
77
+ const {
78
+ colors
79
+ } = useTheme();
80
+ const drawerStatus = getDrawerStatusFromState(state);
81
+ const handleDrawerOpen = React.useCallback(() => {
82
+ navigation.dispatch({ ...DrawerActions.openDrawer(),
83
+ target: state.key
84
+ });
85
+ }, [navigation, state.key]);
86
+ const handleDrawerClose = React.useCallback(() => {
87
+ navigation.dispatch({ ...DrawerActions.closeDrawer(),
88
+ target: state.key
89
+ });
90
+ }, [navigation, state.key]);
91
+ React.useEffect(() => {
92
+ if (drawerStatus !== 'open' || drawerType === 'permanent') {
93
+ return;
94
+ }
95
+
96
+ const handleClose = () => {
97
+ // We shouldn't handle the back button if the parent screen isn't focused
98
+ // This will avoid the drawer overriding event listeners from a focused screen
99
+ if (!navigation.isFocused()) {
100
+ return false;
101
+ }
102
+
103
+ handleDrawerClose();
104
+ return true;
105
+ };
106
+
107
+ const handleEscape = e => {
108
+ if (e.key === 'Escape') {
109
+ handleClose();
110
+ }
111
+ }; // We only add the listeners when drawer opens
112
+ // This way we can make sure that the listener is added as late as possible
113
+ // This will make sure that our handler will run first when back button is pressed
114
+
115
+
116
+ const subscription = BackHandler.addEventListener('hardwareBackPress', handleClose);
117
+
118
+ if (Platform.OS === 'web') {
119
+ var _document, _document$body, _document$body$addEve;
120
+
121
+ (_document = document) === null || _document === void 0 ? void 0 : (_document$body = _document.body) === null || _document$body === void 0 ? void 0 : (_document$body$addEve = _document$body.addEventListener) === null || _document$body$addEve === void 0 ? void 0 : _document$body$addEve.call(_document$body, 'keyup', handleEscape);
122
+ }
123
+
124
+ return () => {
125
+ subscription.remove();
126
+
127
+ if (Platform.OS === 'web') {
128
+ var _document2, _document2$body, _document2$body$remov;
129
+
130
+ (_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
+ }
132
+ };
133
+ }, [drawerStatus, drawerType, handleDrawerClose, navigation]);
134
+
135
+ const renderDrawerContent = () => {
136
+ return /*#__PURE__*/React.createElement(DrawerPositionContext.Provider, {
137
+ value: drawerPosition
138
+ }, drawerContent({
139
+ state: state,
140
+ navigation: navigation,
141
+ descriptors: descriptors
142
+ }));
143
+ };
144
+
145
+ const renderSceneContent = () => {
146
+ return /*#__PURE__*/React.createElement(MaybeScreenContainer, {
147
+ enabled: detachInactiveScreens,
148
+ style: styles.content
149
+ }, state.routes.map((route, index) => {
150
+ const descriptor = descriptors[route.key];
151
+ const {
152
+ lazy = true,
153
+ unmountOnBlur
154
+ } = descriptor.options;
155
+ const isFocused = state.index === index;
156
+
157
+ if (unmountOnBlur && !isFocused) {
158
+ return null;
159
+ }
160
+
161
+ if (lazy && !loaded.includes(route.key) && !isFocused) {
162
+ // Don't render a lazy screen if we've never navigated to it
163
+ return null;
164
+ }
165
+
166
+ const {
167
+ header = ({
168
+ layout,
169
+ options
170
+ }) => {
171
+ var _options$headerLeft;
172
+
173
+ return /*#__PURE__*/React.createElement(Header, _extends({}, options, {
174
+ layout: layout,
175
+ title: getHeaderTitle(options, route.name),
176
+ headerLeft: (_options$headerLeft = options.headerLeft) !== null && _options$headerLeft !== void 0 ? _options$headerLeft : props => /*#__PURE__*/React.createElement(DrawerToggleButton, props)
177
+ }));
178
+ },
179
+ sceneContainerStyle
180
+ } = descriptor.options;
181
+ return /*#__PURE__*/React.createElement(MaybeScreen, {
182
+ key: route.key,
183
+ style: [StyleSheet.absoluteFill, {
184
+ zIndex: isFocused ? 0 : -1
185
+ }],
186
+ visible: isFocused,
187
+ enabled: detachInactiveScreens
188
+ }, /*#__PURE__*/React.createElement(Screen, {
189
+ focused: isFocused,
190
+ route: descriptor.route,
191
+ navigation: descriptor.navigation,
192
+ headerShown: descriptor.options.headerShown,
193
+ headerTransparent: descriptor.options.headerTransparent,
194
+ headerStatusBarHeight: descriptor.options.headerStatusBarHeight,
195
+ header: header({
196
+ layout: dimensions,
197
+ route: descriptor.route,
198
+ navigation: descriptor.navigation,
199
+ options: descriptor.options
200
+ }),
201
+ style: sceneContainerStyle
202
+ }, descriptor.render()));
203
+ }));
204
+ };
205
+
206
+ return /*#__PURE__*/React.createElement(DrawerStatusContext.Provider, {
207
+ value: drawerStatus
208
+ }, /*#__PURE__*/React.createElement(Drawer, {
209
+ open: drawerStatus !== 'closed',
210
+ onOpen: handleDrawerOpen,
211
+ onClose: handleDrawerClose,
212
+ gestureHandlerProps: gestureHandlerProps,
213
+ swipeEnabled: swipeEnabled,
214
+ swipeEdgeWidth: swipeEdgeWidth,
215
+ swipeVelocityThreshold: 500,
216
+ swipeDistanceThreshold: swipeMinDistance,
217
+ hideStatusBarOnOpen: drawerHideStatusBarOnOpen,
218
+ statusBarAnimation: drawerStatusBarAnimation,
219
+ keyboardDismissMode: keyboardDismissMode,
220
+ drawerType: drawerType,
221
+ drawerPosition: drawerPosition,
222
+ drawerStyle: [{
223
+ width: getDefaultDrawerWidth(dimensions),
224
+ backgroundColor: colors.card
225
+ }, drawerType === 'permanent' && (drawerPosition === 'left' ? {
226
+ borderRightColor: colors.border,
227
+ borderRightWidth: StyleSheet.hairlineWidth
228
+ } : {
229
+ borderLeftColor: colors.border,
230
+ borderLeftWidth: StyleSheet.hairlineWidth
231
+ }), drawerStyle],
232
+ overlayStyle: {
233
+ backgroundColor: overlayColor
234
+ },
235
+ renderDrawerContent: renderDrawerContent,
236
+ renderSceneContent: renderSceneContent,
237
+ dimensions: dimensions
238
+ }));
239
+ }
240
+
241
+ export default function DrawerView({
242
+ navigation,
243
+ ...rest
244
+ }) {
245
+ return /*#__PURE__*/React.createElement(SafeAreaProviderCompat, null, /*#__PURE__*/React.createElement(GestureHandlerWrapper, {
246
+ style: styles.content
247
+ }, /*#__PURE__*/React.createElement(DrawerViewBase, _extends({
248
+ navigation: navigation
249
+ }, rest))));
250
+ }
251
+ const styles = StyleSheet.create({
252
+ content: {
253
+ flex: 1
254
+ }
255
+ });
256
+ //# sourceMappingURL=DrawerView.js.map