react-native-drawer-layout 2.0.0 → 3.1.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/LICENSE +21 -0
- package/README.md +235 -35
- package/lib/commonjs/constants.js +15 -0
- package/lib/commonjs/constants.js.map +1 -0
- package/lib/commonjs/index.js +35 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/types.js +6 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/commonjs/utils/DrawerGestureContext.js +12 -0
- package/lib/commonjs/utils/DrawerGestureContext.js.map +1 -0
- package/lib/commonjs/utils/DrawerProgressContext.js +12 -0
- package/lib/commonjs/utils/DrawerProgressContext.js.map +1 -0
- package/lib/commonjs/utils/useDrawerProgress.js +19 -0
- package/lib/commonjs/utils/useDrawerProgress.js.map +1 -0
- package/lib/commonjs/views/Drawer.js +89 -0
- package/lib/commonjs/views/Drawer.js.map +1 -0
- package/lib/commonjs/views/GestureHandler.android.js +17 -0
- package/lib/commonjs/views/GestureHandler.android.js.map +1 -0
- package/lib/commonjs/views/GestureHandler.ios.js +17 -0
- package/lib/commonjs/views/GestureHandler.ios.js.map +1 -0
- package/lib/commonjs/views/GestureHandler.js +33 -0
- package/lib/commonjs/views/GestureHandler.js.map +1 -0
- package/lib/commonjs/views/GestureHandlerNative.js +37 -0
- package/lib/commonjs/views/GestureHandlerNative.js.map +1 -0
- package/lib/commonjs/views/legacy/Drawer.js +419 -0
- package/lib/commonjs/views/legacy/Drawer.js.map +1 -0
- package/lib/commonjs/views/legacy/Overlay.js +74 -0
- package/lib/commonjs/views/legacy/Overlay.js.map +1 -0
- package/lib/commonjs/views/modern/Drawer.js +285 -0
- package/lib/commonjs/views/modern/Drawer.js.map +1 -0
- package/lib/commonjs/views/modern/Overlay.js +69 -0
- package/lib/commonjs/views/modern/Overlay.js.map +1 -0
- package/lib/module/constants.js +5 -0
- package/lib/module/constants.js.map +1 -0
- package/lib/module/index.js +5 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/utils/DrawerGestureContext.js +3 -0
- package/lib/module/utils/DrawerGestureContext.js.map +1 -0
- package/lib/module/utils/DrawerProgressContext.js +3 -0
- package/lib/module/utils/DrawerProgressContext.js.map +1 -0
- package/lib/module/utils/useDrawerProgress.js +10 -0
- package/lib/module/utils/useDrawerProgress.js.map +1 -0
- package/lib/module/views/Drawer.js +81 -0
- package/lib/module/views/Drawer.js.map +1 -0
- package/lib/module/views/GestureHandler.android.js +2 -0
- package/lib/module/views/GestureHandler.android.js.map +1 -0
- package/lib/module/views/GestureHandler.ios.js +2 -0
- package/lib/module/views/GestureHandler.ios.js.map +1 -0
- package/lib/module/views/GestureHandler.js +21 -0
- package/lib/module/views/GestureHandler.js.map +1 -0
- package/lib/module/views/GestureHandlerNative.js +11 -0
- package/lib/module/views/GestureHandlerNative.js.map +1 -0
- package/lib/module/views/legacy/Drawer.js +409 -0
- package/lib/module/views/legacy/Drawer.js.map +1 -0
- package/lib/module/views/legacy/Overlay.js +64 -0
- package/lib/module/views/legacy/Overlay.js.map +1 -0
- package/lib/module/views/modern/Drawer.js +276 -0
- package/lib/module/views/modern/Drawer.js.map +1 -0
- package/lib/module/views/modern/Overlay.js +60 -0
- package/lib/module/views/modern/Overlay.js.map +1 -0
- package/lib/typescript/src/constants.d.ts +5 -0
- package/lib/typescript/src/constants.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +5 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +110 -0
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/lib/typescript/src/utils/DrawerGestureContext.d.ts +4 -0
- package/lib/typescript/src/utils/DrawerGestureContext.d.ts.map +1 -0
- package/lib/typescript/src/utils/DrawerProgressContext.d.ts +5 -0
- package/lib/typescript/src/utils/DrawerProgressContext.d.ts.map +1 -0
- package/lib/typescript/src/utils/useDrawerProgress.d.ts +3 -0
- package/lib/typescript/src/utils/useDrawerProgress.d.ts.map +1 -0
- package/lib/typescript/src/views/Drawer.d.ts +20 -0
- package/lib/typescript/src/views/Drawer.d.ts.map +1 -0
- package/lib/typescript/src/views/GestureHandler.android.d.ts +2 -0
- package/lib/typescript/src/views/GestureHandler.android.d.ts.map +1 -0
- package/lib/typescript/src/views/GestureHandler.d.ts +15 -0
- package/lib/typescript/src/views/GestureHandler.d.ts.map +1 -0
- package/lib/typescript/src/views/GestureHandler.ios.d.ts +2 -0
- package/lib/typescript/src/views/GestureHandler.ios.d.ts.map +1 -0
- package/lib/typescript/src/views/GestureHandlerNative.d.ts +6 -0
- package/lib/typescript/src/views/GestureHandlerNative.d.ts.map +1 -0
- package/lib/typescript/src/views/legacy/Drawer.d.ts +51 -0
- package/lib/typescript/src/views/legacy/Drawer.d.ts.map +1 -0
- package/lib/typescript/src/views/legacy/Overlay.d.ts +89 -0
- package/lib/typescript/src/views/legacy/Overlay.d.ts.map +1 -0
- package/lib/typescript/src/views/modern/Drawer.d.ts +10 -0
- package/lib/typescript/src/views/modern/Drawer.d.ts.map +1 -0
- package/lib/typescript/src/views/modern/Overlay.d.ts +89 -0
- package/lib/typescript/src/views/modern/Overlay.d.ts.map +1 -0
- package/package.json +54 -94
- package/src/constants.tsx +4 -0
- package/src/index.tsx +4 -0
- package/src/types.tsx +122 -0
- package/src/utils/DrawerGestureContext.tsx +3 -0
- package/src/utils/DrawerProgressContext.tsx +6 -0
- package/src/utils/useDrawerProgress.tsx +18 -0
- package/src/views/Drawer.tsx +122 -0
- package/src/views/GestureHandler.android.tsx +1 -0
- package/src/views/GestureHandler.ios.tsx +1 -0
- package/src/views/GestureHandler.tsx +29 -0
- package/src/views/GestureHandlerNative.tsx +24 -0
- package/src/views/legacy/Drawer.tsx +682 -0
- package/src/views/legacy/Overlay.tsx +87 -0
- package/src/views/modern/Drawer.tsx +413 -0
- package/src/views/modern/Overlay.tsx +82 -0
- package/dist/DrawerLayout.js +0 -430
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
3
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
4
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
5
|
+
import * as React from 'react';
|
|
6
|
+
import { I18nManager, InteractionManager, Keyboard, Platform, StatusBar, StyleSheet, View } from 'react-native';
|
|
7
|
+
import Animated from 'react-native-reanimated';
|
|
8
|
+
import { DEFAULT_DRAWER_WIDTH, SWIPE_MIN_DISTANCE, SWIPE_MIN_OFFSET, SWIPE_MIN_VELOCITY } from '../../constants';
|
|
9
|
+
import DrawerProgressContext from '../../utils/DrawerProgressContext';
|
|
10
|
+
import { GestureState, PanGestureHandler } from '../GestureHandler';
|
|
11
|
+
import Overlay from './Overlay';
|
|
12
|
+
const {
|
|
13
|
+
Clock,
|
|
14
|
+
Value,
|
|
15
|
+
onChange,
|
|
16
|
+
clockRunning,
|
|
17
|
+
startClock,
|
|
18
|
+
stopClock,
|
|
19
|
+
spring,
|
|
20
|
+
abs,
|
|
21
|
+
add,
|
|
22
|
+
and,
|
|
23
|
+
block,
|
|
24
|
+
call,
|
|
25
|
+
cond,
|
|
26
|
+
divide,
|
|
27
|
+
eq,
|
|
28
|
+
event,
|
|
29
|
+
greaterThan,
|
|
30
|
+
lessThan,
|
|
31
|
+
max,
|
|
32
|
+
min,
|
|
33
|
+
multiply,
|
|
34
|
+
neq,
|
|
35
|
+
or,
|
|
36
|
+
set,
|
|
37
|
+
sub
|
|
38
|
+
} = Animated;
|
|
39
|
+
const TRUE = 1;
|
|
40
|
+
const FALSE = 0;
|
|
41
|
+
const NOOP = 0;
|
|
42
|
+
const UNSET = -1;
|
|
43
|
+
const DIRECTION_LEFT = 1;
|
|
44
|
+
const DIRECTION_RIGHT = -1;
|
|
45
|
+
const SPRING_CONFIG = {
|
|
46
|
+
stiffness: 1000,
|
|
47
|
+
damping: 500,
|
|
48
|
+
mass: 3,
|
|
49
|
+
overshootClamping: true,
|
|
50
|
+
restDisplacementThreshold: 0.01,
|
|
51
|
+
restSpeedThreshold: 0.01
|
|
52
|
+
};
|
|
53
|
+
const ANIMATED_ZERO = new Animated.Value(0);
|
|
54
|
+
const ANIMATED_ONE = new Animated.Value(1);
|
|
55
|
+
export default class Drawer extends React.Component {
|
|
56
|
+
constructor() {
|
|
57
|
+
super(...arguments);
|
|
58
|
+
_defineProperty(this, "handleEndInteraction", () => {
|
|
59
|
+
if (this.interactionHandle !== undefined) {
|
|
60
|
+
InteractionManager.clearInteractionHandle(this.interactionHandle);
|
|
61
|
+
this.interactionHandle = undefined;
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
_defineProperty(this, "handleStartInteraction", () => {
|
|
65
|
+
if (this.interactionHandle === undefined) {
|
|
66
|
+
this.interactionHandle = InteractionManager.createInteractionHandle();
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
_defineProperty(this, "getDrawerWidth", () => {
|
|
70
|
+
const {
|
|
71
|
+
drawerStyle,
|
|
72
|
+
layout
|
|
73
|
+
} = this.props;
|
|
74
|
+
const {
|
|
75
|
+
width = DEFAULT_DRAWER_WIDTH
|
|
76
|
+
} = StyleSheet.flatten(drawerStyle) || {};
|
|
77
|
+
if (typeof width === 'string' && width.endsWith('%')) {
|
|
78
|
+
// Try to calculate width if a percentage is given
|
|
79
|
+
const percentage = Number(width.replace(/%$/, ''));
|
|
80
|
+
if (Number.isFinite(percentage)) {
|
|
81
|
+
return layout.width * (percentage / 100);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return typeof width === 'number' ? width : 0;
|
|
85
|
+
});
|
|
86
|
+
_defineProperty(this, "clock", new Clock());
|
|
87
|
+
_defineProperty(this, "interactionHandle", void 0);
|
|
88
|
+
_defineProperty(this, "isDrawerTypeFront", new Value(this.props.drawerType === 'front' ? TRUE : FALSE));
|
|
89
|
+
_defineProperty(this, "isOpen", new Value(this.props.open ? TRUE : FALSE));
|
|
90
|
+
_defineProperty(this, "nextIsOpen", new Value(UNSET));
|
|
91
|
+
_defineProperty(this, "isSwiping", new Value(FALSE));
|
|
92
|
+
_defineProperty(this, "initialDrawerWidth", this.getDrawerWidth());
|
|
93
|
+
_defineProperty(this, "gestureState", new Value(GestureState.UNDETERMINED));
|
|
94
|
+
_defineProperty(this, "touchX", new Value(0));
|
|
95
|
+
_defineProperty(this, "velocityX", new Value(0));
|
|
96
|
+
_defineProperty(this, "gestureX", new Value(0));
|
|
97
|
+
_defineProperty(this, "offsetX", new Value(0));
|
|
98
|
+
_defineProperty(this, "position", new Value(this.props.open ? this.initialDrawerWidth * (this.props.drawerPosition === 'right' ? DIRECTION_RIGHT : DIRECTION_LEFT) : 0));
|
|
99
|
+
_defineProperty(this, "containerWidth", new Value(this.props.layout.width));
|
|
100
|
+
_defineProperty(this, "drawerWidth", new Value(this.initialDrawerWidth));
|
|
101
|
+
_defineProperty(this, "drawerOpacity", new Value(this.props.drawerType === 'permanent' ? 1 : 0));
|
|
102
|
+
_defineProperty(this, "drawerPosition", new Value(this.props.drawerPosition === 'right' ? DIRECTION_RIGHT : DIRECTION_LEFT));
|
|
103
|
+
_defineProperty(this, "touchDistanceFromDrawer", cond(this.isDrawerTypeFront, cond(eq(this.drawerPosition, DIRECTION_LEFT), max(
|
|
104
|
+
// Distance of touch start from left screen edge - Drawer width
|
|
105
|
+
sub(sub(this.touchX, this.gestureX), this.drawerWidth), 0), min(multiply(
|
|
106
|
+
// Distance of drawer from left screen edge - Touch start point
|
|
107
|
+
sub(sub(this.containerWidth, this.drawerWidth), sub(this.touchX, this.gestureX)), DIRECTION_RIGHT), 0)), 0));
|
|
108
|
+
_defineProperty(this, "swipeDistanceThreshold", new Value(this.props.swipeMinDistance ?? SWIPE_MIN_DISTANCE));
|
|
109
|
+
_defineProperty(this, "swipeVelocityThreshold", new Value(this.props.swipeMinVelocity ?? SWIPE_MIN_VELOCITY));
|
|
110
|
+
_defineProperty(this, "currentOpenValue", this.props.open);
|
|
111
|
+
_defineProperty(this, "pendingOpenValue", void 0);
|
|
112
|
+
_defineProperty(this, "isStatusBarHidden", false);
|
|
113
|
+
_defineProperty(this, "manuallyTriggerSpring", new Value(FALSE));
|
|
114
|
+
_defineProperty(this, "transitionTo", isOpen => {
|
|
115
|
+
const toValue = new Value(0);
|
|
116
|
+
const frameTime = new Value(0);
|
|
117
|
+
const state = {
|
|
118
|
+
position: this.position,
|
|
119
|
+
time: new Value(0),
|
|
120
|
+
finished: new Value(FALSE),
|
|
121
|
+
velocity: new Value(0)
|
|
122
|
+
};
|
|
123
|
+
return block([cond(clockRunning(this.clock), NOOP, [
|
|
124
|
+
// Animation wasn't running before
|
|
125
|
+
// Set the initial values and start the clock
|
|
126
|
+
set(toValue, multiply(isOpen, this.drawerWidth, this.drawerPosition)), set(frameTime, 0), set(state.time, 0), set(state.finished, FALSE), set(state.velocity, this.velocityX), set(this.isOpen, isOpen), startClock(this.clock), call([], this.handleStartInteraction), set(this.manuallyTriggerSpring, FALSE)]), spring(this.clock, state, {
|
|
127
|
+
...SPRING_CONFIG,
|
|
128
|
+
toValue
|
|
129
|
+
}), cond(state.finished, [
|
|
130
|
+
// Reset gesture and velocity from previous gesture
|
|
131
|
+
set(this.touchX, 0), set(this.gestureX, 0), set(this.velocityX, 0), set(this.offsetX, 0),
|
|
132
|
+
// When the animation finishes, stop the clock
|
|
133
|
+
stopClock(this.clock), call([this.isOpen], _ref => {
|
|
134
|
+
let [value] = _ref;
|
|
135
|
+
const open = Boolean(value);
|
|
136
|
+
this.handleEndInteraction();
|
|
137
|
+
if (open !== this.props.open) {
|
|
138
|
+
// Sync drawer's state after animation finished
|
|
139
|
+
// This shouldn't be necessary, but there seems to be an issue on iOS
|
|
140
|
+
this.toggleDrawer(this.props.open);
|
|
141
|
+
}
|
|
142
|
+
})])]);
|
|
143
|
+
});
|
|
144
|
+
_defineProperty(this, "dragX", block([onChange(this.isOpen, call([this.isOpen], _ref2 => {
|
|
145
|
+
let [value] = _ref2;
|
|
146
|
+
const open = Boolean(value);
|
|
147
|
+
this.currentOpenValue = open;
|
|
148
|
+
|
|
149
|
+
// Without this check, the drawer can go to an infinite update <-> animate loop for sync updates
|
|
150
|
+
if (open !== this.props.open) {
|
|
151
|
+
// If the mode changed, update state
|
|
152
|
+
if (open) {
|
|
153
|
+
this.props.onOpen();
|
|
154
|
+
} else {
|
|
155
|
+
this.props.onClose();
|
|
156
|
+
}
|
|
157
|
+
this.pendingOpenValue = open;
|
|
158
|
+
|
|
159
|
+
// Force componentDidUpdate to fire, whether user does a setState or not
|
|
160
|
+
// This allows us to detect when the user drops the update and revert back
|
|
161
|
+
// It's necessary to make sure that the state stays in sync
|
|
162
|
+
this.forceUpdate();
|
|
163
|
+
}
|
|
164
|
+
})), onChange(this.nextIsOpen, cond(neq(this.nextIsOpen, UNSET), [
|
|
165
|
+
// Stop any running animations
|
|
166
|
+
cond(clockRunning(this.clock), stopClock(this.clock)),
|
|
167
|
+
// Update the open value to trigger the transition
|
|
168
|
+
set(this.isOpen, this.nextIsOpen), set(this.gestureX, 0), set(this.nextIsOpen, UNSET)])),
|
|
169
|
+
// This block must be after the this.isOpen listener since we check for current value
|
|
170
|
+
onChange(this.isSwiping,
|
|
171
|
+
// Listen to updates for this value only when it changes
|
|
172
|
+
// Without `onChange`, this will fire even if the value didn't change
|
|
173
|
+
// We don't want to call the listeners if the value didn't change
|
|
174
|
+
call([this.isSwiping], _ref3 => {
|
|
175
|
+
let [value] = _ref3;
|
|
176
|
+
const {
|
|
177
|
+
keyboardDismissMode
|
|
178
|
+
} = this.props;
|
|
179
|
+
if (value === TRUE) {
|
|
180
|
+
if (keyboardDismissMode === 'on-drag') {
|
|
181
|
+
Keyboard.dismiss();
|
|
182
|
+
}
|
|
183
|
+
this.toggleStatusBar(true);
|
|
184
|
+
} else {
|
|
185
|
+
this.toggleStatusBar(this.currentOpenValue);
|
|
186
|
+
}
|
|
187
|
+
})), onChange(this.gestureState, cond(eq(this.gestureState, GestureState.ACTIVE), call([], this.handleStartInteraction))), cond(eq(this.gestureState, GestureState.ACTIVE), [cond(this.isSwiping, NOOP, [
|
|
188
|
+
// We weren't dragging before, set it to true
|
|
189
|
+
set(this.isSwiping, TRUE),
|
|
190
|
+
// Also update the drag offset to the last position
|
|
191
|
+
set(this.offsetX, this.position)]),
|
|
192
|
+
// Update position with previous offset + gesture distance
|
|
193
|
+
set(this.position, add(this.offsetX, this.gestureX, this.touchDistanceFromDrawer)),
|
|
194
|
+
// Stop animations while we're dragging
|
|
195
|
+
stopClock(this.clock)], [set(this.isSwiping, FALSE), set(this.touchX, 0), this.transitionTo(cond(this.manuallyTriggerSpring, this.isOpen, cond(or(and(greaterThan(abs(this.gestureX), SWIPE_MIN_OFFSET), greaterThan(abs(this.velocityX), this.swipeVelocityThreshold)), greaterThan(abs(this.gestureX), this.swipeDistanceThreshold)), cond(eq(this.drawerPosition, DIRECTION_LEFT),
|
|
196
|
+
// If swiped to right, open the drawer, otherwise close it
|
|
197
|
+
greaterThan(cond(eq(this.velocityX, 0), this.gestureX, this.velocityX), 0),
|
|
198
|
+
// If swiped to left, open the drawer, otherwise close it
|
|
199
|
+
lessThan(cond(eq(this.velocityX, 0), this.gestureX, this.velocityX), 0)), this.isOpen)))]), this.position]));
|
|
200
|
+
_defineProperty(this, "translateX", cond(eq(this.drawerPosition, DIRECTION_RIGHT), min(max(multiply(this.drawerWidth, -1), this.dragX), 0), max(min(this.drawerWidth, this.dragX), 0)));
|
|
201
|
+
_defineProperty(this, "progress", cond(
|
|
202
|
+
// Check if the drawer width is available to avoid division by zero
|
|
203
|
+
eq(this.drawerWidth, 0), 0, abs(divide(this.translateX, this.drawerWidth))));
|
|
204
|
+
_defineProperty(this, "handleGestureEvent", event([{
|
|
205
|
+
nativeEvent: {
|
|
206
|
+
x: this.touchX,
|
|
207
|
+
translationX: this.gestureX,
|
|
208
|
+
velocityX: this.velocityX
|
|
209
|
+
}
|
|
210
|
+
}]));
|
|
211
|
+
_defineProperty(this, "handleGestureStateChange", event([{
|
|
212
|
+
nativeEvent: {
|
|
213
|
+
state: s => set(this.gestureState, s)
|
|
214
|
+
}
|
|
215
|
+
}]));
|
|
216
|
+
_defineProperty(this, "handleContainerLayout", e => this.containerWidth.setValue(e.nativeEvent.layout.width));
|
|
217
|
+
_defineProperty(this, "handleDrawerLayout", e => {
|
|
218
|
+
this.drawerWidth.setValue(e.nativeEvent.layout.width);
|
|
219
|
+
this.toggleDrawer(this.props.open);
|
|
220
|
+
|
|
221
|
+
// Until layout is available, drawer is hidden with opacity: 0 by default
|
|
222
|
+
// Show it in the next frame when layout is available
|
|
223
|
+
// If we don't delay it until the next frame, there's a visible flicker
|
|
224
|
+
requestAnimationFrame(() => requestAnimationFrame(() => this.drawerOpacity.setValue(1)));
|
|
225
|
+
});
|
|
226
|
+
_defineProperty(this, "toggleDrawer", open => {
|
|
227
|
+
if (this.currentOpenValue !== open) {
|
|
228
|
+
this.nextIsOpen.setValue(open ? TRUE : FALSE);
|
|
229
|
+
|
|
230
|
+
// This value will also be set shortly after as changing this.nextIsOpen changes this.isOpen
|
|
231
|
+
// However, there's a race condition on Android, so we need to set a bit earlier
|
|
232
|
+
this.currentOpenValue = open;
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
_defineProperty(this, "toggleStatusBar", hidden => {
|
|
236
|
+
const {
|
|
237
|
+
hideStatusBarOnOpen: hideStatusBar,
|
|
238
|
+
statusBarAnimation
|
|
239
|
+
} = this.props;
|
|
240
|
+
if (hideStatusBar && this.isStatusBarHidden !== hidden) {
|
|
241
|
+
this.isStatusBarHidden = hidden;
|
|
242
|
+
StatusBar.setHidden(hidden, statusBarAnimation);
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
componentDidUpdate(prevProps) {
|
|
247
|
+
const {
|
|
248
|
+
open,
|
|
249
|
+
drawerPosition,
|
|
250
|
+
drawerType,
|
|
251
|
+
swipeMinDistance,
|
|
252
|
+
swipeMinVelocity,
|
|
253
|
+
hideStatusBarOnOpen
|
|
254
|
+
} = this.props;
|
|
255
|
+
if (
|
|
256
|
+
// If we're not in the middle of a transition, sync the drawer's open state
|
|
257
|
+
typeof this.pendingOpenValue !== 'boolean' || open !== this.pendingOpenValue) {
|
|
258
|
+
this.toggleDrawer(open);
|
|
259
|
+
}
|
|
260
|
+
this.pendingOpenValue = undefined;
|
|
261
|
+
if (open !== prevProps.open && hideStatusBarOnOpen) {
|
|
262
|
+
this.toggleStatusBar(open);
|
|
263
|
+
}
|
|
264
|
+
if (prevProps.drawerPosition !== drawerPosition) {
|
|
265
|
+
this.drawerPosition.setValue(drawerPosition === 'right' ? DIRECTION_RIGHT : DIRECTION_LEFT);
|
|
266
|
+
}
|
|
267
|
+
if (prevProps.drawerType !== drawerType) {
|
|
268
|
+
this.isDrawerTypeFront.setValue(drawerType === 'front' ? TRUE : FALSE);
|
|
269
|
+
}
|
|
270
|
+
if (prevProps.swipeMinDistance !== swipeMinDistance) {
|
|
271
|
+
this.swipeDistanceThreshold.setValue(swipeMinDistance ?? SWIPE_MIN_DISTANCE);
|
|
272
|
+
}
|
|
273
|
+
if (prevProps.swipeMinVelocity !== swipeMinVelocity) {
|
|
274
|
+
this.swipeVelocityThreshold.setValue(swipeMinVelocity ?? SWIPE_MIN_VELOCITY);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
componentWillUnmount() {
|
|
278
|
+
this.toggleStatusBar(false);
|
|
279
|
+
this.handleEndInteraction();
|
|
280
|
+
}
|
|
281
|
+
render() {
|
|
282
|
+
const {
|
|
283
|
+
open,
|
|
284
|
+
swipeEnabled,
|
|
285
|
+
drawerPosition,
|
|
286
|
+
drawerType,
|
|
287
|
+
swipeEdgeWidth,
|
|
288
|
+
drawerStyle,
|
|
289
|
+
overlayStyle,
|
|
290
|
+
renderDrawerContent,
|
|
291
|
+
children,
|
|
292
|
+
gestureHandlerProps,
|
|
293
|
+
overlayAccessibilityLabel
|
|
294
|
+
} = this.props;
|
|
295
|
+
const isOpen = drawerType === 'permanent' ? true : open;
|
|
296
|
+
const isRight = drawerPosition === 'right';
|
|
297
|
+
const contentTranslateX = drawerType === 'front' ? ANIMATED_ZERO : this.translateX;
|
|
298
|
+
const drawerTranslateX = drawerType === 'back' ? I18nManager.getConstants().isRTL ? multiply(sub(this.containerWidth, this.drawerWidth), isRight ? 1 : -1) : ANIMATED_ZERO : this.translateX;
|
|
299
|
+
const offset = drawerType === 'back' ? 0 : I18nManager.getConstants().isRTL ? '100%' : multiply(this.drawerWidth, -1);
|
|
300
|
+
|
|
301
|
+
// FIXME: Currently hitSlop is broken when on Android when drawer is on right
|
|
302
|
+
// https://github.com/software-mansion/react-native-gesture-handler/issues/569
|
|
303
|
+
const hitSlop = isRight ?
|
|
304
|
+
// Extend hitSlop to the side of the screen when drawer is closed
|
|
305
|
+
// This lets the user drag the drawer from the side of the screen
|
|
306
|
+
{
|
|
307
|
+
right: 0,
|
|
308
|
+
width: isOpen ? undefined : swipeEdgeWidth
|
|
309
|
+
} : {
|
|
310
|
+
left: 0,
|
|
311
|
+
width: isOpen ? undefined : swipeEdgeWidth
|
|
312
|
+
};
|
|
313
|
+
const progress = drawerType === 'permanent' ? ANIMATED_ONE : this.progress;
|
|
314
|
+
return /*#__PURE__*/React.createElement(DrawerProgressContext.Provider, {
|
|
315
|
+
value: progress
|
|
316
|
+
}, /*#__PURE__*/React.createElement(PanGestureHandler, _extends({
|
|
317
|
+
activeOffsetX: [-SWIPE_MIN_OFFSET, SWIPE_MIN_OFFSET],
|
|
318
|
+
failOffsetY: [-SWIPE_MIN_OFFSET, SWIPE_MIN_OFFSET],
|
|
319
|
+
onGestureEvent: this.handleGestureEvent,
|
|
320
|
+
onHandlerStateChange: this.handleGestureStateChange,
|
|
321
|
+
hitSlop: hitSlop,
|
|
322
|
+
enabled: drawerType !== 'permanent' && swipeEnabled
|
|
323
|
+
}, gestureHandlerProps), /*#__PURE__*/React.createElement(Animated.View, {
|
|
324
|
+
onLayout: this.handleContainerLayout,
|
|
325
|
+
style: [styles.main, {
|
|
326
|
+
flexDirection: drawerType === 'permanent' && !isRight ? 'row-reverse' : 'row'
|
|
327
|
+
}]
|
|
328
|
+
}, /*#__PURE__*/React.createElement(Animated.View, {
|
|
329
|
+
style: [styles.content, {
|
|
330
|
+
transform: drawerType === 'permanent' ?
|
|
331
|
+
// Reanimated needs the property to be present, but it results in Browser bug
|
|
332
|
+
// https://bugs.chromium.org/p/chromium/issues/detail?id=20574
|
|
333
|
+
[] : [{
|
|
334
|
+
translateX: contentTranslateX
|
|
335
|
+
}]
|
|
336
|
+
}]
|
|
337
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
338
|
+
accessibilityElementsHidden: isOpen && drawerType !== 'permanent',
|
|
339
|
+
importantForAccessibility: isOpen && drawerType !== 'permanent' ? 'no-hide-descendants' : 'auto',
|
|
340
|
+
style: styles.content
|
|
341
|
+
}, children),
|
|
342
|
+
// Disable overlay if sidebar is permanent
|
|
343
|
+
drawerType === 'permanent' ? null : /*#__PURE__*/React.createElement(Overlay, {
|
|
344
|
+
progress: progress,
|
|
345
|
+
onPress: () => this.toggleDrawer(false),
|
|
346
|
+
accessibilityLabel: overlayAccessibilityLabel,
|
|
347
|
+
style: overlayStyle,
|
|
348
|
+
accessibilityElementsHidden: !isOpen,
|
|
349
|
+
importantForAccessibility: isOpen ? 'auto' : 'no-hide-descendants'
|
|
350
|
+
})), /*#__PURE__*/React.createElement(Animated.Code, {
|
|
351
|
+
// This is needed to make sure that container width updates with `setValue`
|
|
352
|
+
// Without this, it won't update when not used in styles
|
|
353
|
+
exec: this.containerWidth
|
|
354
|
+
}), drawerType === 'permanent' ? null : /*#__PURE__*/React.createElement(Animated.Code, {
|
|
355
|
+
exec: block([onChange(this.manuallyTriggerSpring, [cond(eq(this.manuallyTriggerSpring, TRUE), [set(this.nextIsOpen, FALSE), call([], () => this.currentOpenValue = false)])])])
|
|
356
|
+
}), /*#__PURE__*/React.createElement(Animated.View, {
|
|
357
|
+
removeClippedSubviews: Platform.OS !== 'ios',
|
|
358
|
+
onLayout: this.handleDrawerLayout,
|
|
359
|
+
style: [styles.container, {
|
|
360
|
+
transform: drawerType === 'permanent' ?
|
|
361
|
+
// Reanimated needs the property to be present, but it results in Browser bug
|
|
362
|
+
// https://bugs.chromium.org/p/chromium/issues/detail?id=20574
|
|
363
|
+
[] : [{
|
|
364
|
+
translateX: drawerTranslateX
|
|
365
|
+
}],
|
|
366
|
+
opacity: this.drawerOpacity
|
|
367
|
+
}, drawerType === 'permanent' ?
|
|
368
|
+
// Without this, the `left`/`right` values don't get reset
|
|
369
|
+
isRight ? {
|
|
370
|
+
right: 0
|
|
371
|
+
} : {
|
|
372
|
+
left: 0
|
|
373
|
+
} : [styles.nonPermanent, isRight ? {
|
|
374
|
+
right: offset
|
|
375
|
+
} : {
|
|
376
|
+
left: offset
|
|
377
|
+
}, {
|
|
378
|
+
zIndex: drawerType === 'back' ? -1 : 0
|
|
379
|
+
}], drawerStyle]
|
|
380
|
+
}, renderDrawerContent()))));
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
const styles = StyleSheet.create({
|
|
384
|
+
container: {
|
|
385
|
+
backgroundColor: 'white',
|
|
386
|
+
maxWidth: '100%'
|
|
387
|
+
},
|
|
388
|
+
nonPermanent: {
|
|
389
|
+
position: 'absolute',
|
|
390
|
+
top: 0,
|
|
391
|
+
bottom: 0,
|
|
392
|
+
width: DEFAULT_DRAWER_WIDTH
|
|
393
|
+
},
|
|
394
|
+
content: {
|
|
395
|
+
flex: 1
|
|
396
|
+
},
|
|
397
|
+
main: {
|
|
398
|
+
flex: 1,
|
|
399
|
+
...Platform.select({
|
|
400
|
+
// FIXME: We need to hide `overflowX` on Web so the translated content doesn't show offscreen.
|
|
401
|
+
// But adding `overflowX: 'hidden'` prevents content from collapsing the URL bar.
|
|
402
|
+
web: null,
|
|
403
|
+
default: {
|
|
404
|
+
overflow: 'hidden'
|
|
405
|
+
}
|
|
406
|
+
})
|
|
407
|
+
}
|
|
408
|
+
});
|
|
409
|
+
//# sourceMappingURL=Drawer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","I18nManager","InteractionManager","Keyboard","Platform","StatusBar","StyleSheet","View","Animated","DEFAULT_DRAWER_WIDTH","SWIPE_MIN_DISTANCE","SWIPE_MIN_OFFSET","SWIPE_MIN_VELOCITY","DrawerProgressContext","GestureState","PanGestureHandler","Overlay","Clock","Value","onChange","clockRunning","startClock","stopClock","spring","abs","add","and","block","call","cond","divide","eq","event","greaterThan","lessThan","max","min","multiply","neq","or","set","sub","TRUE","FALSE","NOOP","UNSET","DIRECTION_LEFT","DIRECTION_RIGHT","SPRING_CONFIG","stiffness","damping","mass","overshootClamping","restDisplacementThreshold","restSpeedThreshold","ANIMATED_ZERO","ANIMATED_ONE","Drawer","Component","interactionHandle","undefined","clearInteractionHandle","createInteractionHandle","drawerStyle","layout","props","width","flatten","endsWith","percentage","Number","replace","isFinite","drawerType","open","getDrawerWidth","UNDETERMINED","initialDrawerWidth","drawerPosition","isDrawerTypeFront","touchX","gestureX","drawerWidth","containerWidth","swipeMinDistance","swipeMinVelocity","isOpen","toValue","frameTime","state","position","time","finished","velocity","clock","velocityX","handleStartInteraction","manuallyTriggerSpring","offsetX","value","Boolean","handleEndInteraction","toggleDrawer","currentOpenValue","onOpen","onClose","pendingOpenValue","forceUpdate","nextIsOpen","isSwiping","keyboardDismissMode","dismiss","toggleStatusBar","gestureState","ACTIVE","touchDistanceFromDrawer","transitionTo","swipeVelocityThreshold","swipeDistanceThreshold","dragX","translateX","nativeEvent","x","translationX","s","e","setValue","requestAnimationFrame","drawerOpacity","hidden","hideStatusBarOnOpen","hideStatusBar","statusBarAnimation","isStatusBarHidden","setHidden","componentDidUpdate","prevProps","componentWillUnmount","render","swipeEnabled","swipeEdgeWidth","overlayStyle","renderDrawerContent","children","gestureHandlerProps","overlayAccessibilityLabel","isRight","contentTranslateX","drawerTranslateX","getConstants","isRTL","offset","hitSlop","right","left","progress","handleGestureEvent","handleGestureStateChange","handleContainerLayout","styles","main","flexDirection","content","transform","OS","handleDrawerLayout","container","opacity","nonPermanent","zIndex","create","backgroundColor","maxWidth","top","bottom","flex","select","web","default","overflow"],"sourceRoot":"../../src","sources":["Drawer.tsx"],"mappings":";;;;AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SACEC,WAAW,EACXC,kBAAkB,EAClBC,QAAQ,EAERC,QAAQ,EACRC,SAAS,EACTC,UAAU,EACVC,IAAI,QACC,cAAc;AACrB,OAAOC,QAAQ,MAAM,yBAAyB;AAE9C,SACEC,oBAAoB,EACpBC,kBAAkB,EAClBC,gBAAgB,EAChBC,kBAAkB,QACb,iBAAiB;AAExB,OAAOC,qBAAqB,MAAM,mCAAmC;AACrE,SAASC,YAAY,EAAEC,iBAAiB,QAAQ,mBAAmB;AACnE,OAAOC,OAAO,MAAM,WAAW;AAE/B,MAAM;EACJC,KAAK;EACLC,KAAK;EACLC,QAAQ;EACRC,YAAY;EACZC,UAAU;EACVC,SAAS;EACTC,MAAM;EACNC,GAAG;EACHC,GAAG;EACHC,GAAG;EACHC,KAAK;EACLC,IAAI;EACJC,IAAI;EACJC,MAAM;EACNC,EAAE;EACFC,KAAK;EACLC,WAAW;EACXC,QAAQ;EACRC,GAAG;EACH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,CAAC;IACP,GAAG3K,QAAQ,CAAC4K,MAAM,CAAC;MACjB;MACA;MACAC,GAAG,EAAE,IAAI;MACTC,OAAO,EAAE;QAAEC,QAAQ,EAAE;MAAS;IAChC,CAAC;EACH;AACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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
|
+
import * as React from 'react';
|
|
3
|
+
import { Platform, Pressable, StyleSheet } from 'react-native';
|
|
4
|
+
import Animated from 'react-native-reanimated';
|
|
5
|
+
const {
|
|
6
|
+
// @ts-expect-error: this is to support reanimated 1
|
|
7
|
+
interpolate: interpolateDeprecated,
|
|
8
|
+
interpolateNode,
|
|
9
|
+
cond,
|
|
10
|
+
greaterThan
|
|
11
|
+
} = Animated;
|
|
12
|
+
const interpolate = interpolateNode ?? interpolateDeprecated;
|
|
13
|
+
const PROGRESS_EPSILON = 0.05;
|
|
14
|
+
const Overlay = /*#__PURE__*/React.forwardRef(function Overlay(_ref, ref) {
|
|
15
|
+
let {
|
|
16
|
+
progress,
|
|
17
|
+
onPress,
|
|
18
|
+
style,
|
|
19
|
+
accessibilityLabel = 'Close drawer',
|
|
20
|
+
...props
|
|
21
|
+
} = _ref;
|
|
22
|
+
const animatedStyle = {
|
|
23
|
+
opacity: interpolate(progress, {
|
|
24
|
+
// Default input range is [PROGRESS_EPSILON, 1]
|
|
25
|
+
// On Windows, the output value is 1 when input value is out of range for some reason
|
|
26
|
+
// The default value 0 will be interpolated to 1 in this case, which is not what we want.
|
|
27
|
+
// Therefore changing input range on Windows to [0,1] instead.
|
|
28
|
+
inputRange: Platform.OS === 'windows' || Platform.OS === 'macos' ? [0, 1] : [PROGRESS_EPSILON, 1],
|
|
29
|
+
outputRange: [0, 1]
|
|
30
|
+
}),
|
|
31
|
+
// We don't want the user to be able to press through the overlay when drawer is open
|
|
32
|
+
// One approach is to adjust the pointerEvents based on the progress
|
|
33
|
+
// But we can also send the overlay behind the screen, which works, and is much less code
|
|
34
|
+
zIndex: cond(greaterThan(progress, PROGRESS_EPSILON), 0, -1)
|
|
35
|
+
};
|
|
36
|
+
return /*#__PURE__*/React.createElement(Animated.View, _extends({}, props, {
|
|
37
|
+
ref: ref,
|
|
38
|
+
style: [styles.overlay, overlayStyle, animatedStyle, style]
|
|
39
|
+
}), /*#__PURE__*/React.createElement(Pressable, {
|
|
40
|
+
onPress: onPress,
|
|
41
|
+
style: styles.pressable,
|
|
42
|
+
accessibilityRole: "button",
|
|
43
|
+
accessibilityLabel: accessibilityLabel
|
|
44
|
+
}));
|
|
45
|
+
});
|
|
46
|
+
const overlayStyle = Platform.select({
|
|
47
|
+
web: {
|
|
48
|
+
// Disable touch highlight on mobile Safari.
|
|
49
|
+
// WebkitTapHighlightColor must be used outside of StyleSheet.create because react-native-web will omit the property.
|
|
50
|
+
WebkitTapHighlightColor: 'transparent'
|
|
51
|
+
},
|
|
52
|
+
default: {}
|
|
53
|
+
});
|
|
54
|
+
const styles = StyleSheet.create({
|
|
55
|
+
overlay: {
|
|
56
|
+
...StyleSheet.absoluteFillObject,
|
|
57
|
+
backgroundColor: 'rgba(0, 0, 0, 0.5)'
|
|
58
|
+
},
|
|
59
|
+
pressable: {
|
|
60
|
+
flex: 1
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
export default Overlay;
|
|
64
|
+
//# sourceMappingURL=Overlay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","Platform","Pressable","StyleSheet","Animated","interpolate","interpolateDeprecated","interpolateNode","cond","greaterThan","PROGRESS_EPSILON","Overlay","forwardRef","ref","progress","onPress","style","accessibilityLabel","props","animatedStyle","opacity","inputRange","OS","outputRange","zIndex","styles","overlay","overlayStyle","pressable","select","web","WebkitTapHighlightColor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