@react-navigation/drawer 8.0.0-alpha.2 → 8.0.0-alpha.21
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/module/utils/useDrawerStatus.js +1 -1
- package/lib/module/utils/useDrawerStatus.js.map +1 -1
- package/lib/module/views/DrawerContentScrollView.js +23 -14
- package/lib/module/views/DrawerContentScrollView.js.map +1 -1
- package/lib/module/views/DrawerItem.js +50 -8
- package/lib/module/views/DrawerItem.js.map +1 -1
- package/lib/module/views/DrawerItemList.js +3 -1
- package/lib/module/views/DrawerItemList.js.map +1 -1
- package/lib/module/views/DrawerToggleButton.js +37 -7
- package/lib/module/views/DrawerToggleButton.js.map +1 -1
- package/lib/module/views/DrawerView.js +14 -15
- package/lib/module/views/DrawerView.js.map +1 -1
- package/lib/typescript/src/types.d.ts +20 -17
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/lib/typescript/src/views/DrawerContentScrollView.d.ts.map +1 -1
- package/lib/typescript/src/views/DrawerItem.d.ts +18 -17
- package/lib/typescript/src/views/DrawerItem.d.ts.map +1 -1
- package/lib/typescript/src/views/DrawerItemList.d.ts.map +1 -1
- package/lib/typescript/src/views/DrawerToggleButton.d.ts +12 -7
- package/lib/typescript/src/views/DrawerToggleButton.d.ts.map +1 -1
- package/lib/typescript/src/views/DrawerView.d.ts.map +1 -1
- package/package.json +20 -19
- package/src/types.tsx +26 -20
- package/src/utils/useDrawerStatus.tsx +1 -1
- package/src/views/DrawerContentScrollView.tsx +28 -18
- package/src/views/DrawerItem.tsx +84 -23
- package/src/views/DrawerItemList.tsx +2 -0
- package/src/views/DrawerToggleButton.tsx +66 -22
- package/src/views/DrawerView.tsx +18 -18
- package/lib/module/views/assets/toggle-drawer-icon@1x.android.png +0 -0
- package/lib/module/views/assets/toggle-drawer-icon@1x.ios.png +0 -0
- package/lib/module/views/assets/toggle-drawer-icon@2x.android.png +0 -0
- package/lib/module/views/assets/toggle-drawer-icon@2x.ios.png +0 -0
- package/lib/module/views/assets/toggle-drawer-icon@3x.android.png +0 -0
- package/lib/module/views/assets/toggle-drawer-icon@3x.ios.png +0 -0
- package/lib/module/views/assets/toggle-drawer-icon@4x.android.png +0 -0
- package/lib/module/views/assets/toggle-drawer-icon@4x.ios.png +0 -0
- package/src/views/assets/toggle-drawer-icon@1x.android.png +0 -0
- package/src/views/assets/toggle-drawer-icon@1x.ios.png +0 -0
- package/src/views/assets/toggle-drawer-icon@2x.android.png +0 -0
- package/src/views/assets/toggle-drawer-icon@2x.ios.png +0 -0
- package/src/views/assets/toggle-drawer-icon@3x.android.png +0 -0
- package/src/views/assets/toggle-drawer-icon@3x.ios.png +0 -0
- package/src/views/assets/toggle-drawer-icon@4x.android.png +0 -0
- package/src/views/assets/toggle-drawer-icon@4x.ios.png +0 -0
|
@@ -1,15 +1,16 @@
|
|
|
1
|
+
import { type Icon } from '@react-navigation/elements';
|
|
1
2
|
import { type Route } from '@react-navigation/native';
|
|
2
|
-
import
|
|
3
|
+
import React from 'react';
|
|
3
4
|
import { type ColorValue, type StyleProp, type TextStyle, type ViewStyle } from 'react-native';
|
|
4
5
|
type Props = {
|
|
5
6
|
/**
|
|
6
7
|
* The route object which should be specified by the drawer item.
|
|
7
8
|
*/
|
|
8
|
-
route?: Route<string
|
|
9
|
+
route?: Route<string> | undefined;
|
|
9
10
|
/**
|
|
10
11
|
* The `href` to use for the anchor tag on web
|
|
11
12
|
*/
|
|
12
|
-
href?: string;
|
|
13
|
+
href?: string | undefined;
|
|
13
14
|
/**
|
|
14
15
|
* The label text of the item.
|
|
15
16
|
*/
|
|
@@ -20,15 +21,15 @@ type Props = {
|
|
|
20
21
|
/**
|
|
21
22
|
* Icon to display for the `DrawerItem`.
|
|
22
23
|
*/
|
|
23
|
-
icon?: (props: {
|
|
24
|
+
icon?: Icon | ((props: {
|
|
24
25
|
focused: boolean;
|
|
25
26
|
size: number;
|
|
26
27
|
color: ColorValue;
|
|
27
|
-
}) => React.ReactNode;
|
|
28
|
+
}) => Icon | React.ReactNode) | undefined;
|
|
28
29
|
/**
|
|
29
30
|
* Whether to highlight the drawer item as active.
|
|
30
31
|
*/
|
|
31
|
-
focused?: boolean;
|
|
32
|
+
focused?: boolean | undefined;
|
|
32
33
|
/**
|
|
33
34
|
* Function to execute on press.
|
|
34
35
|
*/
|
|
@@ -36,53 +37,53 @@ type Props = {
|
|
|
36
37
|
/**
|
|
37
38
|
* Color for the icon and label when the item is active.
|
|
38
39
|
*/
|
|
39
|
-
activeTintColor?: ColorValue;
|
|
40
|
+
activeTintColor?: ColorValue | undefined;
|
|
40
41
|
/**
|
|
41
42
|
* Color for the icon and label when the item is inactive.
|
|
42
43
|
*/
|
|
43
|
-
inactiveTintColor?: ColorValue;
|
|
44
|
+
inactiveTintColor?: ColorValue | undefined;
|
|
44
45
|
/**
|
|
45
46
|
* Background color for item when its active.
|
|
46
47
|
*/
|
|
47
|
-
activeBackgroundColor?: ColorValue;
|
|
48
|
+
activeBackgroundColor?: ColorValue | undefined;
|
|
48
49
|
/**
|
|
49
50
|
* Background color for item when its inactive.
|
|
50
51
|
*/
|
|
51
|
-
inactiveBackgroundColor?: ColorValue;
|
|
52
|
+
inactiveBackgroundColor?: ColorValue | undefined;
|
|
52
53
|
/**
|
|
53
54
|
* Color of the touchable effect on press.
|
|
54
55
|
* Only supported on Android.
|
|
55
56
|
*
|
|
56
57
|
* @platform android
|
|
57
58
|
*/
|
|
58
|
-
pressColor?: ColorValue;
|
|
59
|
+
pressColor?: ColorValue | undefined;
|
|
59
60
|
/**
|
|
60
61
|
* Opacity of the touchable effect on press.
|
|
61
62
|
* Only supported on iOS.
|
|
62
63
|
*
|
|
63
64
|
* @platform ios
|
|
64
65
|
*/
|
|
65
|
-
pressOpacity?: number;
|
|
66
|
+
pressOpacity?: number | undefined;
|
|
66
67
|
/**
|
|
67
68
|
* Style object for the label element.
|
|
68
69
|
*/
|
|
69
|
-
labelStyle?: StyleProp<TextStyle
|
|
70
|
+
labelStyle?: StyleProp<TextStyle> | undefined;
|
|
70
71
|
/**
|
|
71
72
|
* Style object for the wrapper element.
|
|
72
73
|
*/
|
|
73
|
-
style?: StyleProp<ViewStyle
|
|
74
|
+
style?: StyleProp<ViewStyle> | undefined;
|
|
74
75
|
/**
|
|
75
76
|
* Whether label font should scale to respect Text Size accessibility settings.
|
|
76
77
|
*/
|
|
77
|
-
allowFontScaling?: boolean;
|
|
78
|
+
allowFontScaling?: boolean | undefined;
|
|
78
79
|
/**
|
|
79
80
|
* Accessibility label for drawer item.
|
|
80
81
|
*/
|
|
81
|
-
accessibilityLabel?: string;
|
|
82
|
+
accessibilityLabel?: string | undefined;
|
|
82
83
|
/**
|
|
83
84
|
* ID to locate this drawer item in tests.
|
|
84
85
|
*/
|
|
85
|
-
testID?: string;
|
|
86
|
+
testID?: string | undefined;
|
|
86
87
|
};
|
|
87
88
|
/**
|
|
88
89
|
* A component used to show an action item with an icon and a label in a navigation drawer.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DrawerItem.d.ts","sourceRoot":"","sources":["../../../../src/views/DrawerItem.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DrawerItem.d.ts","sourceRoot":"","sources":["../../../../src/views/DrawerItem.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,EAA2B,MAAM,4BAA4B,CAAC;AAEhF,OAAO,EAEL,KAAK,KAAK,EAGX,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EACL,KAAK,UAAU,EAGf,KAAK,SAAS,EAEd,KAAK,SAAS,EAEd,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAEtB,KAAK,KAAK,GAAG;IACX;;OAEG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;IAClC;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B;;OAEG;IACH,KAAK,EACD,MAAM,GACN,CAAC,CAAC,KAAK,EAAE;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,UAAU,CAAA;KAAE,KAAK,KAAK,CAAC,SAAS,CAAC,CAAC;IAC1E;;OAEG;IACH,IAAI,CAAC,EACD,IAAI,GACJ,CAAC,CAAC,KAAK,EAAE;QACP,OAAO,EAAE,OAAO,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,UAAU,CAAC;KACnB,KAAK,IAAI,GAAG,KAAK,CAAC,SAAS,CAAC,GAC7B,SAAS,CAAC;IACd;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B;;OAEG;IACH,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB;;OAEG;IACH,eAAe,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;IACzC;;OAEG;IACH,iBAAiB,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;IAC3C;;OAEG;IACH,qBAAqB,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;IAC/C;;OAEG;IACH,uBAAuB,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;IACjD;;;;;OAKG;IACH,UAAU,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;IACpC;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC;;OAEG;IACH,UAAU,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC;IAC9C;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC;IACzC;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAEvC;;OAEG;IACH,kBAAkB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7B,CAAC;AAEF;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,KAAK,2CA8HtC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DrawerItemList.d.ts","sourceRoot":"","sources":["../../../../src/views/DrawerItemList.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,qBAAqB,EAC1B,KAAK,aAAa,EAEnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAG7E,KAAK,KAAK,GAAG;IACX,KAAK,EAAE,qBAAqB,CAAC,aAAa,CAAC,CAAC;IAC5C,UAAU,EAAE,uBAAuB,CAAC;IACpC,WAAW,EAAE,mBAAmB,CAAC;CAClC,CAAC;AAEF;;GAEG;AACH,wBAAgB,cAAc,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"DrawerItemList.d.ts","sourceRoot":"","sources":["../../../../src/views/DrawerItemList.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,qBAAqB,EAC1B,KAAK,aAAa,EAEnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAG7E,KAAK,KAAK,GAAG;IACX,KAAK,EAAE,qBAAqB,CAAC,aAAa,CAAC,CAAC;IAC5C,UAAU,EAAE,uBAAuB,CAAC;IACpC,WAAW,EAAE,mBAAmB,CAAC;CAClC,CAAC;AAEF;;GAEG;AACH,wBAAgB,cAAc,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,EAAE,KAAK,GAqE7C,KAAK,CAAC,YAAY,CAC5C"}
|
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type Icon } from '@react-navigation/elements';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { type ColorValue } from 'react-native';
|
|
2
4
|
type Props = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
icon?: Icon | ((props: {
|
|
6
|
+
tintColor: ColorValue | undefined;
|
|
7
|
+
}) => React.ReactNode) | undefined;
|
|
8
|
+
accessibilityLabel?: string | undefined;
|
|
9
|
+
pressColor?: ColorValue | undefined;
|
|
10
|
+
pressOpacity?: number | undefined;
|
|
11
|
+
tintColor?: ColorValue | undefined;
|
|
12
|
+
testID?: string | undefined;
|
|
8
13
|
};
|
|
9
|
-
export declare function DrawerToggleButton({ tintColor, accessibilityLabel,
|
|
14
|
+
export declare function DrawerToggleButton({ icon, tintColor, accessibilityLabel, ...rest }: Props): import("react/jsx-runtime").JSX.Element;
|
|
10
15
|
export {};
|
|
11
16
|
//# sourceMappingURL=DrawerToggleButton.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DrawerToggleButton.d.ts","sourceRoot":"","sources":["../../../../src/views/DrawerToggleButton.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DrawerToggleButton.d.ts","sourceRoot":"","sources":["../../../../src/views/DrawerToggleButton.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAOrE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,KAAK,UAAU,EAA+B,MAAM,cAAc,CAAC;AAI5E,KAAK,KAAK,GAAG;IACX,IAAI,CAAC,EACD,IAAI,GACJ,CAAC,CAAC,KAAK,EAAE;QAAE,SAAS,EAAE,UAAU,GAAG,SAAS,CAAA;KAAE,KAAK,KAAK,CAAC,SAAS,CAAC,GACnE,SAAS,CAAC;IACd,kBAAkB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,UAAU,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;IACpC,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,SAAS,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;IACnC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7B,CAAC;AAEF,wBAAgB,kBAAkB,CAAC,EACjC,IAAI,EACJ,SAAS,EACT,kBAA2C,EAC3C,GAAG,IAAI,EACR,EAAE,KAAK,2CAuDP"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DrawerView.d.ts","sourceRoot":"","sources":["../../../../src/views/DrawerView.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DrawerView.d.ts","sourceRoot":"","sources":["../../../../src/views/DrawerView.tsx"],"names":[],"mappings":"AAOA,OAAO,EAEL,KAAK,qBAAqB,EAC1B,KAAK,YAAY,EACjB,KAAK,aAAa,EAInB,MAAM,0BAA0B,CAAC;AAMlC,OAAO,KAAK,EAEV,mBAAmB,EAEnB,sBAAsB,EACtB,uBAAuB,EAExB,MAAM,UAAU,CAAC;AAQlB,KAAK,KAAK,GAAG,sBAAsB,GAAG;IACpC,aAAa,EAAE,YAAY,CAAC;IAC5B,KAAK,EAAE,qBAAqB,CAAC,aAAa,CAAC,CAAC;IAC5C,UAAU,EAAE,uBAAuB,CAAC;IACpC,WAAW,EAAE,mBAAmB,CAAC;CAClC,CAAC;AAqTF,wBAAgB,UAAU,CAAC,EAAE,UAAU,EAAE,GAAG,IAAI,EAAE,EAAE,KAAK,2CAMxD"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-navigation/drawer",
|
|
3
3
|
"description": "Integration for the drawer component from react-native-drawer-layout",
|
|
4
|
-
"version": "8.0.0-alpha.
|
|
4
|
+
"version": "8.0.0-alpha.21",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react-native-component",
|
|
7
7
|
"react-component",
|
|
@@ -46,36 +46,37 @@
|
|
|
46
46
|
"clean": "del lib"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@react-navigation/elements": "^3.0.0-alpha.
|
|
49
|
+
"@react-navigation/elements": "^3.0.0-alpha.19",
|
|
50
50
|
"color": "^4.2.3",
|
|
51
|
-
"react-native-drawer-layout": "^5.0.0-alpha.
|
|
51
|
+
"react-native-drawer-layout": "^5.0.0-alpha.5",
|
|
52
52
|
"use-latest-callback": "^0.3.2"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@jest/globals": "^30.0.0",
|
|
56
|
-
"@react-navigation/native": "^8.0.0-alpha.
|
|
57
|
-
"@testing-library/react-native": "^13.
|
|
58
|
-
"@types/react": "~19.
|
|
56
|
+
"@react-navigation/native": "^8.0.0-alpha.17",
|
|
57
|
+
"@testing-library/react-native": "^13.3.3",
|
|
58
|
+
"@types/react": "~19.2.2",
|
|
59
59
|
"del-cli": "^6.0.0",
|
|
60
|
-
"react": "19.
|
|
61
|
-
"react-native": "0.
|
|
60
|
+
"react": "19.2.0",
|
|
61
|
+
"react-native": "0.83.2",
|
|
62
62
|
"react-native-builder-bob": "^0.40.12",
|
|
63
|
-
"react-native-gesture-handler": "~2.
|
|
64
|
-
"react-native-reanimated": "4.1
|
|
65
|
-
"react-native-safe-area-context": "~5.6.
|
|
66
|
-
"react-native-screens": "^4.
|
|
67
|
-
"react-native-worklets": "0.
|
|
68
|
-
"react-test-renderer": "19.
|
|
69
|
-
"typescript": "^
|
|
63
|
+
"react-native-gesture-handler": "~2.30.0",
|
|
64
|
+
"react-native-reanimated": "~4.2.1",
|
|
65
|
+
"react-native-safe-area-context": "~5.6.2",
|
|
66
|
+
"react-native-screens": "^4.24.0",
|
|
67
|
+
"react-native-worklets": "0.7.2",
|
|
68
|
+
"react-test-renderer": "19.2.0",
|
|
69
|
+
"typescript": "^6.0.2"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
|
-
"@react-navigation/native": "^8.0.0-alpha.
|
|
73
|
-
"react": ">= 19.
|
|
72
|
+
"@react-navigation/native": "^8.0.0-alpha.17",
|
|
73
|
+
"react": ">= 19.2.0",
|
|
74
74
|
"react-native": "*",
|
|
75
75
|
"react-native-gesture-handler": ">= 2.0.0",
|
|
76
76
|
"react-native-reanimated": ">= 4.0.0",
|
|
77
77
|
"react-native-safe-area-context": ">= 5.5.0",
|
|
78
|
-
"react-native-screens": ">= 4.
|
|
78
|
+
"react-native-screens": ">= 4.24.0",
|
|
79
|
+
"react-native-worklets": ">= 0.4.0"
|
|
79
80
|
},
|
|
80
81
|
"react-native-builder-bob": {
|
|
81
82
|
"source": "src",
|
|
@@ -95,5 +96,5 @@
|
|
|
95
96
|
]
|
|
96
97
|
]
|
|
97
98
|
},
|
|
98
|
-
"gitHead": "
|
|
99
|
+
"gitHead": "71f3b00d579a18e8a67d96722862deddc876a3f7"
|
|
99
100
|
}
|
package/src/types.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { HeaderOptions } from '@react-navigation/elements';
|
|
1
|
+
import type { HeaderOptions, Icon } from '@react-navigation/elements';
|
|
2
|
+
import type { Screen } from '@react-navigation/elements/internal';
|
|
2
3
|
import type {
|
|
3
4
|
DefaultNavigatorOptions,
|
|
4
5
|
Descriptor,
|
|
@@ -29,12 +30,6 @@ export type DrawerNavigationConfig = {
|
|
|
29
30
|
* Defaults to `DrawerContent`.
|
|
30
31
|
*/
|
|
31
32
|
drawerContent?: (props: DrawerContentComponentProps) => React.ReactNode;
|
|
32
|
-
/**
|
|
33
|
-
* Whether inactive screens should be detached from the view hierarchy to save memory.
|
|
34
|
-
* Make sure to call `enableScreens` from `react-native-screens` to make it work.
|
|
35
|
-
* Defaults to `true`.
|
|
36
|
-
*/
|
|
37
|
-
detachInactiveScreens?: boolean;
|
|
38
33
|
};
|
|
39
34
|
|
|
40
35
|
export type DrawerNavigationOptions = HeaderOptions & {
|
|
@@ -70,13 +65,15 @@ export type DrawerNavigationOptions = HeaderOptions & {
|
|
|
70
65
|
| ((props: { color: ColorValue; focused: boolean }) => React.ReactNode);
|
|
71
66
|
|
|
72
67
|
/**
|
|
73
|
-
*
|
|
68
|
+
* Icon to display for the drawer item.
|
|
74
69
|
*/
|
|
75
|
-
drawerIcon?:
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
70
|
+
drawerIcon?:
|
|
71
|
+
| Icon
|
|
72
|
+
| ((props: {
|
|
73
|
+
color: ColorValue;
|
|
74
|
+
size: number;
|
|
75
|
+
focused: boolean;
|
|
76
|
+
}) => Icon | React.ReactNode);
|
|
80
77
|
|
|
81
78
|
/**
|
|
82
79
|
* Color for the icon and label in the active item in the drawer.
|
|
@@ -108,6 +105,11 @@ export type DrawerNavigationOptions = HeaderOptions & {
|
|
|
108
105
|
*/
|
|
109
106
|
drawerItemStyle?: StyleProp<ViewStyle>;
|
|
110
107
|
|
|
108
|
+
/**
|
|
109
|
+
* ID to locate this drawer item in tests.
|
|
110
|
+
*/
|
|
111
|
+
drawerItemTestID?: string;
|
|
112
|
+
|
|
111
113
|
/**
|
|
112
114
|
* Style object to apply to the `Text` inside content section which renders a label.
|
|
113
115
|
*/
|
|
@@ -143,7 +145,7 @@ export type DrawerNavigationOptions = HeaderOptions & {
|
|
|
143
145
|
*
|
|
144
146
|
* Defaults to `slide` on iOS and `front` on other platforms.
|
|
145
147
|
*/
|
|
146
|
-
drawerType?: 'front' | 'back' | 'slide' | 'permanent';
|
|
148
|
+
drawerType?: 'front' | 'back' | 'slide' | 'permanent' | undefined;
|
|
147
149
|
|
|
148
150
|
/**
|
|
149
151
|
* Whether the statusbar should be hidden when the drawer is pulled or opens,
|
|
@@ -170,7 +172,7 @@ export type DrawerNavigationOptions = HeaderOptions & {
|
|
|
170
172
|
/**
|
|
171
173
|
* Style object for the component wrapping the screen content.
|
|
172
174
|
*/
|
|
173
|
-
sceneStyle?:
|
|
175
|
+
sceneStyle?: React.ComponentProps<typeof Screen>['style'];
|
|
174
176
|
|
|
175
177
|
/**
|
|
176
178
|
* Function to modify the pan gesture handler via RNGH properties API.
|
|
@@ -208,13 +210,17 @@ export type DrawerNavigationOptions = HeaderOptions & {
|
|
|
208
210
|
popToTopOnBlur?: boolean;
|
|
209
211
|
|
|
210
212
|
/**
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
213
|
+
* What should happen when screens become inactive.
|
|
214
|
+
* - `pause`: Effects are cleaned up.
|
|
215
|
+
* - `none`: Screen renders normally
|
|
216
|
+
*
|
|
217
|
+
* Defaults to `pause`.
|
|
214
218
|
*
|
|
215
|
-
*
|
|
219
|
+
* If you set `lazy: false` or preload a screen,
|
|
220
|
+
* It won't be paused until after the first time it becomes focused.
|
|
221
|
+
* This makes sure that effects are run to initialize the screen.
|
|
216
222
|
*/
|
|
217
|
-
|
|
223
|
+
inactiveBehavior?: 'pause' | 'none';
|
|
218
224
|
};
|
|
219
225
|
|
|
220
226
|
export type DrawerContentComponentProps = {
|
|
@@ -8,7 +8,7 @@ import { DrawerStatusContext } from './DrawerStatusContext';
|
|
|
8
8
|
* Returns 'open' if the drawer is open, 'closed' if the drawer is closed.
|
|
9
9
|
*/
|
|
10
10
|
export function useDrawerStatus(): DrawerStatus {
|
|
11
|
-
const drawerStatus = React.
|
|
11
|
+
const drawerStatus = React.use(DrawerStatusContext);
|
|
12
12
|
|
|
13
13
|
if (drawerStatus === undefined) {
|
|
14
14
|
throw new Error(
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useLocale } from '@react-navigation/native';
|
|
1
|
+
import { UNSTABLE_CornerInset, useLocale } from '@react-navigation/native';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { ScrollView, type ScrollViewProps, StyleSheet } from 'react-native';
|
|
4
4
|
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
@@ -15,7 +15,7 @@ function DrawerContentScrollViewInner(
|
|
|
15
15
|
{ contentContainerStyle, style, children, ...rest }: Props,
|
|
16
16
|
ref?: React.Ref<ScrollView>
|
|
17
17
|
) {
|
|
18
|
-
const drawerPosition = React.
|
|
18
|
+
const drawerPosition = React.use(DrawerPositionContext);
|
|
19
19
|
const insets = useSafeAreaInsets();
|
|
20
20
|
const { direction } = useLocale();
|
|
21
21
|
|
|
@@ -25,22 +25,32 @@ function DrawerContentScrollViewInner(
|
|
|
25
25
|
: drawerPosition === 'right';
|
|
26
26
|
|
|
27
27
|
return (
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
{
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
28
|
+
<>
|
|
29
|
+
<ScrollView
|
|
30
|
+
{...rest}
|
|
31
|
+
ref={ref}
|
|
32
|
+
contentContainerStyle={[
|
|
33
|
+
{
|
|
34
|
+
paddingBottom: SPACING + insets.bottom,
|
|
35
|
+
paddingStart: SPACING + (!isRight ? insets.left : 0),
|
|
36
|
+
paddingEnd: SPACING + (isRight ? insets.right : 0),
|
|
37
|
+
},
|
|
38
|
+
contentContainerStyle,
|
|
39
|
+
]}
|
|
40
|
+
style={[styles.container, style]}
|
|
41
|
+
>
|
|
42
|
+
<UNSTABLE_CornerInset
|
|
43
|
+
direction="vertical"
|
|
44
|
+
edge="top"
|
|
45
|
+
style={{
|
|
46
|
+
// We don't want to apply both safe area and corner insets
|
|
47
|
+
minHeight: insets.top,
|
|
48
|
+
marginBottom: SPACING,
|
|
49
|
+
}}
|
|
50
|
+
/>
|
|
51
|
+
{children}
|
|
52
|
+
</ScrollView>
|
|
53
|
+
</>
|
|
44
54
|
);
|
|
45
55
|
}
|
|
46
56
|
|
package/src/views/DrawerItem.tsx
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import { PlatformPressable, Text } from '@react-navigation/elements';
|
|
1
|
+
import { type Icon, PlatformPressable, Text } from '@react-navigation/elements';
|
|
2
2
|
import { Color } from '@react-navigation/elements/internal';
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import {
|
|
4
|
+
MaterialSymbol,
|
|
5
|
+
type Route,
|
|
6
|
+
SFSymbol,
|
|
7
|
+
useTheme,
|
|
8
|
+
} from '@react-navigation/native';
|
|
9
|
+
import React from 'react';
|
|
5
10
|
import {
|
|
6
11
|
type ColorValue,
|
|
12
|
+
Image,
|
|
7
13
|
Platform,
|
|
8
14
|
type StyleProp,
|
|
9
15
|
StyleSheet,
|
|
@@ -16,11 +22,11 @@ type Props = {
|
|
|
16
22
|
/**
|
|
17
23
|
* The route object which should be specified by the drawer item.
|
|
18
24
|
*/
|
|
19
|
-
route?: Route<string
|
|
25
|
+
route?: Route<string> | undefined;
|
|
20
26
|
/**
|
|
21
27
|
* The `href` to use for the anchor tag on web
|
|
22
28
|
*/
|
|
23
|
-
href?: string;
|
|
29
|
+
href?: string | undefined;
|
|
24
30
|
/**
|
|
25
31
|
* The label text of the item.
|
|
26
32
|
*/
|
|
@@ -30,15 +36,18 @@ type Props = {
|
|
|
30
36
|
/**
|
|
31
37
|
* Icon to display for the `DrawerItem`.
|
|
32
38
|
*/
|
|
33
|
-
icon?:
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
39
|
+
icon?:
|
|
40
|
+
| Icon
|
|
41
|
+
| ((props: {
|
|
42
|
+
focused: boolean;
|
|
43
|
+
size: number;
|
|
44
|
+
color: ColorValue;
|
|
45
|
+
}) => Icon | React.ReactNode)
|
|
46
|
+
| undefined;
|
|
38
47
|
/**
|
|
39
48
|
* Whether to highlight the drawer item as active.
|
|
40
49
|
*/
|
|
41
|
-
focused?: boolean;
|
|
50
|
+
focused?: boolean | undefined;
|
|
42
51
|
/**
|
|
43
52
|
* Function to execute on press.
|
|
44
53
|
*/
|
|
@@ -46,54 +55,54 @@ type Props = {
|
|
|
46
55
|
/**
|
|
47
56
|
* Color for the icon and label when the item is active.
|
|
48
57
|
*/
|
|
49
|
-
activeTintColor?: ColorValue;
|
|
58
|
+
activeTintColor?: ColorValue | undefined;
|
|
50
59
|
/**
|
|
51
60
|
* Color for the icon and label when the item is inactive.
|
|
52
61
|
*/
|
|
53
|
-
inactiveTintColor?: ColorValue;
|
|
62
|
+
inactiveTintColor?: ColorValue | undefined;
|
|
54
63
|
/**
|
|
55
64
|
* Background color for item when its active.
|
|
56
65
|
*/
|
|
57
|
-
activeBackgroundColor?: ColorValue;
|
|
66
|
+
activeBackgroundColor?: ColorValue | undefined;
|
|
58
67
|
/**
|
|
59
68
|
* Background color for item when its inactive.
|
|
60
69
|
*/
|
|
61
|
-
inactiveBackgroundColor?: ColorValue;
|
|
70
|
+
inactiveBackgroundColor?: ColorValue | undefined;
|
|
62
71
|
/**
|
|
63
72
|
* Color of the touchable effect on press.
|
|
64
73
|
* Only supported on Android.
|
|
65
74
|
*
|
|
66
75
|
* @platform android
|
|
67
76
|
*/
|
|
68
|
-
pressColor?: ColorValue;
|
|
77
|
+
pressColor?: ColorValue | undefined;
|
|
69
78
|
/**
|
|
70
79
|
* Opacity of the touchable effect on press.
|
|
71
80
|
* Only supported on iOS.
|
|
72
81
|
*
|
|
73
82
|
* @platform ios
|
|
74
83
|
*/
|
|
75
|
-
pressOpacity?: number;
|
|
84
|
+
pressOpacity?: number | undefined;
|
|
76
85
|
/**
|
|
77
86
|
* Style object for the label element.
|
|
78
87
|
*/
|
|
79
|
-
labelStyle?: StyleProp<TextStyle
|
|
88
|
+
labelStyle?: StyleProp<TextStyle> | undefined;
|
|
80
89
|
/**
|
|
81
90
|
* Style object for the wrapper element.
|
|
82
91
|
*/
|
|
83
|
-
style?: StyleProp<ViewStyle
|
|
92
|
+
style?: StyleProp<ViewStyle> | undefined;
|
|
84
93
|
/**
|
|
85
94
|
* Whether label font should scale to respect Text Size accessibility settings.
|
|
86
95
|
*/
|
|
87
|
-
allowFontScaling?: boolean;
|
|
96
|
+
allowFontScaling?: boolean | undefined;
|
|
88
97
|
|
|
89
98
|
/**
|
|
90
99
|
* Accessibility label for drawer item.
|
|
91
100
|
*/
|
|
92
|
-
accessibilityLabel?: string;
|
|
101
|
+
accessibilityLabel?: string | undefined;
|
|
93
102
|
/**
|
|
94
103
|
* ID to locate this drawer item in tests.
|
|
95
104
|
*/
|
|
96
|
-
testID?: string;
|
|
105
|
+
testID?: string | undefined;
|
|
97
106
|
};
|
|
98
107
|
|
|
99
108
|
/**
|
|
@@ -134,7 +143,59 @@ export function DrawerItem(props: Props) {
|
|
|
134
143
|
'rgba(0, 0, 0, 0.06)')
|
|
135
144
|
: inactiveBackgroundColor;
|
|
136
145
|
|
|
137
|
-
const iconNode =
|
|
146
|
+
const iconNode = React.useMemo(() => {
|
|
147
|
+
if (!icon) {
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const size = 24;
|
|
152
|
+
|
|
153
|
+
const iconValue =
|
|
154
|
+
typeof icon === 'function' ? icon({ size, focused, color }) : icon;
|
|
155
|
+
|
|
156
|
+
if (React.isValidElement(iconValue)) {
|
|
157
|
+
return iconValue;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (
|
|
161
|
+
typeof iconValue === 'object' &&
|
|
162
|
+
iconValue != null &&
|
|
163
|
+
'type' in iconValue
|
|
164
|
+
) {
|
|
165
|
+
switch (iconValue.type) {
|
|
166
|
+
case 'image':
|
|
167
|
+
return (
|
|
168
|
+
<Image
|
|
169
|
+
source={iconValue.source}
|
|
170
|
+
style={{
|
|
171
|
+
width: size,
|
|
172
|
+
height: size,
|
|
173
|
+
tintColor: iconValue.tinted === false ? undefined : color,
|
|
174
|
+
}}
|
|
175
|
+
/>
|
|
176
|
+
);
|
|
177
|
+
case 'sfSymbol':
|
|
178
|
+
return <SFSymbol name={iconValue.name} size={size} color={color} />;
|
|
179
|
+
case 'materialSymbol':
|
|
180
|
+
return (
|
|
181
|
+
<MaterialSymbol
|
|
182
|
+
name={iconValue.name}
|
|
183
|
+
variant={iconValue.variant}
|
|
184
|
+
weight={iconValue.weight}
|
|
185
|
+
size={size}
|
|
186
|
+
color={color}
|
|
187
|
+
/>
|
|
188
|
+
);
|
|
189
|
+
default: {
|
|
190
|
+
const _exhaustiveCheck: never = iconValue;
|
|
191
|
+
|
|
192
|
+
return _exhaustiveCheck;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
return null;
|
|
198
|
+
}, [icon, focused, color]);
|
|
138
199
|
|
|
139
200
|
return (
|
|
140
201
|
<View
|
|
@@ -59,6 +59,7 @@ export function DrawerItemList({ state, navigation, descriptors }: Props) {
|
|
|
59
59
|
drawerIcon,
|
|
60
60
|
drawerLabelStyle,
|
|
61
61
|
drawerItemStyle,
|
|
62
|
+
drawerItemTestID,
|
|
62
63
|
drawerAllowFontScaling,
|
|
63
64
|
} = descriptors[route.key].options;
|
|
64
65
|
|
|
@@ -84,6 +85,7 @@ export function DrawerItemList({ state, navigation, descriptors }: Props) {
|
|
|
84
85
|
labelStyle={drawerLabelStyle}
|
|
85
86
|
style={drawerItemStyle}
|
|
86
87
|
onPress={onPress}
|
|
88
|
+
testID={drawerItemTestID}
|
|
87
89
|
/>
|
|
88
90
|
);
|
|
89
91
|
}) as React.ReactNode as React.ReactElement;
|