1 | import * as React from 'react';
|
2 | import { Component } from 'react';
|
3 | import { Animated, StatusBarAnimation, StyleProp, ViewStyle } from 'react-native';
|
4 | import { UserSelect, ActiveCursor, MouseButton } from '../handlers/gestureHandlerCommon';
|
5 | import { PanGestureHandler } from '../handlers/PanGestureHandler';
|
6 | export type DrawerPosition = 'left' | 'right';
|
7 | export type DrawerState = 'Idle' | 'Dragging' | 'Settling';
|
8 | export type DrawerType = 'front' | 'back' | 'slide';
|
9 | export type DrawerLockMode = 'unlocked' | 'locked-closed' | 'locked-open';
|
10 | export type DrawerKeyboardDismissMode = 'none' | 'on-drag';
|
11 | type AnimatedInterpolation = ReturnType<Animated.Value['interpolate']>;
|
12 | export interface DrawerLayoutProps {
|
13 | |
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | renderNavigationView: (progressAnimatedValue: Animated.Value) => React.ReactNode;
|
23 | drawerPosition?: DrawerPosition;
|
24 | drawerWidth?: number;
|
25 | drawerBackgroundColor?: string;
|
26 | drawerLockMode?: DrawerLockMode;
|
27 | keyboardDismissMode?: DrawerKeyboardDismissMode;
|
28 | |
29 |
|
30 |
|
31 | onDrawerClose?: () => void;
|
32 | |
33 |
|
34 |
|
35 | onDrawerOpen?: () => void;
|
36 | |
37 |
|
38 |
|
39 | onDrawerStateChanged?: (newState: DrawerState, drawerWillShow: boolean) => void;
|
40 | useNativeAnimations?: boolean;
|
41 | drawerType?: DrawerType;
|
42 | |
43 |
|
44 |
|
45 |
|
46 | edgeWidth?: number;
|
47 | minSwipeDistance?: number;
|
48 | |
49 |
|
50 |
|
51 |
|
52 |
|
53 | hideStatusBar?: boolean;
|
54 | |
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 | statusBarAnimation?: StatusBarAnimation;
|
63 | |
64 |
|
65 |
|
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 | overlayColor?: string;
|
72 | contentContainerStyle?: StyleProp<ViewStyle>;
|
73 | drawerContainerStyle?: StyleProp<ViewStyle>;
|
74 | |
75 |
|
76 |
|
77 |
|
78 |
|
79 |
|
80 | enableTrackpadTwoFingerGesture?: boolean;
|
81 | onDrawerSlide?: (position: number) => void;
|
82 | onGestureRef?: (ref: PanGestureHandler) => void;
|
83 | children?: React.ReactNode | ((openValue?: AnimatedInterpolation) => React.ReactNode);
|
84 | /**
|
85 | * @default 'none'
|
86 | * Defines which userSelect property should be used.
|
87 | * Values: 'none'|'text'|'auto'
|
88 | */
|
89 | userSelect?: UserSelect;
|
90 | /**
|
91 | * @default 'auto'
|
92 | * Defines which cursor property should be used when gesture activates.
|
93 | * Values: see CSS cursor values
|
94 | */
|
95 | activeCursor?: ActiveCursor;
|
96 | /**
|
97 | * @default 'MouseButton.LEFT'
|
98 | * Allows to choose which mouse button should underlying pan handler react to.
|
99 | */
|
100 | mouseButton?: MouseButton;
|
101 | /**
|
102 | * @default 'false if MouseButton.RIGHT is specified'
|
103 | * Allows to enable/disable context menu.
|
104 | */
|
105 | enableContextMenu?: boolean;
|
106 | }
|
107 | export type DrawerLayoutState = {
|
108 | dragX: Animated.Value;
|
109 | touchX: Animated.Value;
|
110 | drawerTranslation: Animated.Value;
|
111 | containerWidth: number;
|
112 | drawerState: DrawerState;
|
113 | drawerOpened: boolean;
|
114 | };
|
115 | export type DrawerMovementOption = {
|
116 | velocity?: number;
|
117 | speed?: number;
|
118 | };
|
119 | export default class DrawerLayout extends Component<DrawerLayoutProps, DrawerLayoutState> {
|
120 | static defaultProps: {
|
121 | drawerWidth: number;
|
122 | drawerPosition: string;
|
123 | useNativeAnimations: boolean;
|
124 | drawerType: string;
|
125 | edgeWidth: number;
|
126 | minSwipeDistance: number;
|
127 | overlayColor: string;
|
128 | drawerLockMode: string;
|
129 | enableTrackpadTwoFingerGesture: boolean;
|
130 | };
|
131 | constructor(props: DrawerLayoutProps);
|
132 | shouldComponentUpdate(props: DrawerLayoutProps, state: DrawerLayoutState): boolean;
|
133 | private openValue?;
|
134 | private onGestureEvent?;
|
135 | private accessibilityIsModalView;
|
136 | private pointerEventsView;
|
137 | private panGestureHandler;
|
138 | private drawerShown;
|
139 | static positions: {
|
140 | Left: string;
|
141 | Right: string;
|
142 | };
|
143 | private updateAnimatedEvent;
|
144 | private handleContainerLayout;
|
145 | private emitStateChanged;
|
146 | private openingHandlerStateChange;
|
147 | private onTapHandlerStateChange;
|
148 | private handleRelease;
|
149 | private updateShowing;
|
150 | private animateDrawer;
|
151 | openDrawer: (options?: DrawerMovementOption) => void;
|
152 | closeDrawer: (options?: DrawerMovementOption) => void;
|
153 | private renderOverlay;
|
154 | private renderDrawer;
|
155 | private setPanGestureRef;
|
156 | render(): React.JSX.Element;
|
157 | }
|
158 | export {};
|