@wavemaker/rn-codegen 11.7.0-next.139430 → 11.7.0-next.139432
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.
- rn-codegen/command.js +19 -8
- rn-codegen/command.js.map +1 -1
- rn-codegen/index.js +26 -0
- rn-codegen/index.js.map +1 -1
- rn-codegen/package.json +42 -42
- rn-codegen/src/app.generator.js +3 -1
- rn-codegen/src/app.generator.js.map +1 -1
- rn-codegen/src/templates/app.template +3 -0
- rn-codegen/src/templates/babel.config.js.template +7 -1
- rn-codegen/src/templates/component/component.template +1 -1
- rn-codegen/src/templates/package.web.json +50 -53
- rn-codegen/src/templates/project/app.json +11 -1
- rn-codegen/src/templates/project/esbuild/@react-navigation/drawer/6.6.3/lib/module/views/modern/Drawer.js +303 -0
- rn-codegen/src/templates/project/esbuild/@react-navigation/drawer/6.6.3/lib/module/views/modern/Overlay.js +60 -0
- rn-codegen/src/templates/project/esbuild/esbuild.script.js +110 -1
- rn-codegen/src/templates/project/metro.config.js +2 -0
- rn-codegen/src/templates/project/package-lock.json +5671 -6017
- rn-codegen/src/templates/project/package.json +51 -54
- rn-codegen/src/templates/project/revert-to-1.0.styles.js +5 -2
- rn-codegen/src/templates/project/scripts/post-build.js +13 -0
- rn-codegen/src/theme/components/basic/lottie.styledef.js +6 -0
- rn-codegen/src/theme/components/basic/lottie.styledef.js.map +1 -1
- rn-codegen/src/theme/components/chart/area-chart.styledef.js +18 -0
- rn-codegen/src/theme/components/chart/area-chart.styledef.js.map +1 -1
- rn-codegen/src/theme/components/chart/bar-chart.styledef.js +19 -2
- rn-codegen/src/theme/components/chart/bar-chart.styledef.js.map +1 -1
- rn-codegen/src/theme/components/chart/bubble-chart.styledef.js +19 -2
- rn-codegen/src/theme/components/chart/bubble-chart.styledef.js.map +1 -1
- rn-codegen/src/theme/components/chart/column-chart.styledef.js +18 -0
- rn-codegen/src/theme/components/chart/column-chart.styledef.js.map +1 -1
- rn-codegen/src/theme/components/chart/donut-chart.styledef.js +25 -2
- rn-codegen/src/theme/components/chart/donut-chart.styledef.js.map +1 -1
- rn-codegen/src/theme/components/chart/line-chart.styledef.js +18 -0
- rn-codegen/src/theme/components/chart/line-chart.styledef.js.map +1 -1
- rn-codegen/src/theme/components/chart/pie-chart.styledef.js +18 -0
- rn-codegen/src/theme/components/chart/pie-chart.styledef.js.map +1 -1
- rn-codegen/src/theme/variables.js +0 -3
- rn-codegen/src/theme/variables.js.map +1 -1
- rn-codegen/src/transpile/components/advanced/carousel/carousel-template.transformer.js +2 -2
- rn-codegen/src/transpile/components/advanced/carousel/carousel-template.transformer.js.map +1 -1
- rn-codegen/src/transpile/components/basic/search.transformer.js +2 -1
- rn-codegen/src/transpile/components/basic/search.transformer.js.map +1 -1
- rn-codegen/src/transpile/components/chart/area-chart.transformer.js +2 -1
- rn-codegen/src/transpile/components/chart/area-chart.transformer.js.map +1 -1
- rn-codegen/src/transpile/components/chart/bar-chart.transformer.js +2 -1
- rn-codegen/src/transpile/components/chart/bar-chart.transformer.js.map +1 -1
- rn-codegen/src/transpile/components/chart/bubble-chart.transformer.js +2 -1
- rn-codegen/src/transpile/components/chart/bubble-chart.transformer.js.map +1 -1
- rn-codegen/src/transpile/components/chart/column-chart.transformer.js +2 -1
- rn-codegen/src/transpile/components/chart/column-chart.transformer.js.map +1 -1
- rn-codegen/src/transpile/components/chart/donut-chart.transformer.js +7 -2
- rn-codegen/src/transpile/components/chart/donut-chart.transformer.js.map +1 -1
- rn-codegen/src/transpile/components/chart/line-chart.transformer.js +2 -1
- rn-codegen/src/transpile/components/chart/line-chart.transformer.js.map +1 -1
- rn-codegen/src/transpile/components/chart/pie-chart.transformer.js +2 -1
- rn-codegen/src/transpile/components/chart/pie-chart.transformer.js.map +1 -1
- rn-codegen/src/transpile/components/chart/stack-chart.transformer.js +2 -1
- rn-codegen/src/transpile/components/chart/stack-chart.transformer.js.map +1 -1
- rn-codegen/src/transpile/components/input/checkboxset.transformer.js +2 -1
- rn-codegen/src/transpile/components/input/checkboxset.transformer.js.map +1 -1
- rn-codegen/src/transpile/components/input/radioset.transformer.js +2 -1
- rn-codegen/src/transpile/components/input/radioset.transformer.js.map +1 -1
- rn-codegen/src/transpile/components/page/partial-container.transformer.js +1 -1
- rn-codegen/src/transpile/components/page/partial-container.transformer.js.map +1 -1
- rn-codegen/src/transpile/components/prefab/prefab.transformer.js +1 -1
- rn-codegen/src/transpile/components/prefab/prefab.transformer.js.map +1 -1
- rn-codegen/src/transpile/components/utils.js +21 -1
- rn-codegen/src/transpile/components/utils.js.map +1 -1
- rn-codegen/src/transpile/property/property-parser.js +3 -1
- rn-codegen/src/transpile/property/property-parser.js.map +1 -1
- rn-codegen/src/transpile/style/background-image.parser.js +1 -1
- rn-codegen/src/transpile/style/background-image.parser.js.map +1 -1
- rn-codegen/src/transpile/transpile.js +1 -0
- rn-codegen/src/transpile/transpile.js.map +1 -1
- rn-codegen/src/utils.js +1 -20
- rn-codegen/src/utils.js.map +1 -1
|
@@ -9,67 +9,68 @@
|
|
|
9
9
|
"postinstall": "echo \"\""
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@
|
|
13
|
-
"@wavemaker/
|
|
14
|
-
"@wavemaker/
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"expo": "
|
|
20
|
-
"
|
|
21
|
-
"expo-
|
|
22
|
-
"expo-
|
|
23
|
-
"expo-
|
|
24
|
-
"expo-
|
|
25
|
-
"expo-
|
|
26
|
-
"expo-
|
|
27
|
-
"expo-
|
|
28
|
-
"expo-
|
|
29
|
-
"expo-
|
|
30
|
-
"expo-
|
|
31
|
-
"expo-
|
|
32
|
-
"expo-
|
|
33
|
-
"expo-
|
|
34
|
-
"expo-
|
|
35
|
-
"expo-
|
|
12
|
+
"@wavemaker/app-rn-runtime": "11.7.0-next.139432",
|
|
13
|
+
"@wavemaker/variables": "11.7.0-next.139432",
|
|
14
|
+
"@wavemaker/rn-codegen": "11.7.0-next.139432",
|
|
15
|
+
"deprecated-react-native-prop-types": "4.1.0",
|
|
16
|
+
"expo": "50.0.17",
|
|
17
|
+
"expo-build-properties": "0.12.0",
|
|
18
|
+
"@expo/vector-icons": "14.0.0",
|
|
19
|
+
"@expo/metro-runtime": "3.1.3",
|
|
20
|
+
"expo-font": "11.10.3",
|
|
21
|
+
"expo-file-system": "16.0.9",
|
|
22
|
+
"expo-camera": "14.1.3",
|
|
23
|
+
"expo-av": "13.10.6",
|
|
24
|
+
"expo-barcode-scanner": "12.9.3",
|
|
25
|
+
"expo-web-browser": "12.8.2",
|
|
26
|
+
"expo-device": "5.9.4",
|
|
27
|
+
"expo-network": "5.8.0",
|
|
28
|
+
"expo-location": "16.5.5",
|
|
29
|
+
"expo-localization": "14.8.4",
|
|
30
|
+
"expo-contacts": "12.8.2",
|
|
31
|
+
"expo-calendar": "12.2.1",
|
|
32
|
+
"expo-splash-screen": "0.26.5",
|
|
33
|
+
"expo-document-picker": "11.10.1",
|
|
34
|
+
"expo-constants": "15.4.6",
|
|
35
|
+
"expo-modules-core": "1.11.13",
|
|
36
36
|
"@react-native/assets": "1.0.0",
|
|
37
37
|
"hermes-engine": "0.11.0",
|
|
38
|
-
"imask": "
|
|
38
|
+
"imask": "7.6.0",
|
|
39
39
|
"react": "18.2.0",
|
|
40
40
|
"react-dom": "18.2.0",
|
|
41
|
-
"react-native": "0.
|
|
42
|
-
"react-native-web": "0.
|
|
43
|
-
"@react-native
|
|
44
|
-
"@react-native-
|
|
45
|
-
"react-native-
|
|
46
|
-
"react-native-
|
|
41
|
+
"react-native": "0.73.6",
|
|
42
|
+
"react-native-web": "0.19.6",
|
|
43
|
+
"@react-native/assets-registry": "0.74.83",
|
|
44
|
+
"@react-native-async-storage/async-storage": "1.21.0",
|
|
45
|
+
"@react-native-community/netinfo": "11.1.0",
|
|
46
|
+
"react-native-gesture-handler": "2.14.0",
|
|
47
|
+
"react-native-reanimated": "3.6.2",
|
|
47
48
|
"react-native-bundle-splitter": "2.2.3",
|
|
48
|
-
"react-native-safe-area-context": "4.
|
|
49
|
-
"@react-native-community/datetimepicker": "7.
|
|
50
|
-
"@react-native-community/slider": "4.
|
|
51
|
-
"react-native-circular-progress": "1.
|
|
52
|
-
"@react-native-masked-view/masked-view": "0.
|
|
49
|
+
"react-native-safe-area-context": "4.8.2",
|
|
50
|
+
"@react-native-community/datetimepicker": "7.6.3",
|
|
51
|
+
"@react-native-community/slider": "4.5.2",
|
|
52
|
+
"react-native-circular-progress": "1.4.0",
|
|
53
|
+
"@react-native-masked-view/masked-view": "0.3.0",
|
|
53
54
|
"react-native-snap-carousel": "3.9.1",
|
|
54
55
|
"react-native-svg": "13.4.0",
|
|
55
|
-
"react-native-ssl-public-key-pinning": "1.
|
|
56
|
+
"react-native-ssl-public-key-pinning": "1.2.3",
|
|
56
57
|
"@wavemaker/react-native-ssl-publickey": "1.0.2",
|
|
57
58
|
"victory-native": "36.6.11",
|
|
58
59
|
"@react-navigation/native": "6.1.7",
|
|
59
|
-
"react-native-pager-view": "6.2.
|
|
60
|
-
"react-native-webview": "13.
|
|
61
|
-
"react-native-vector-icons": "10.0.
|
|
60
|
+
"react-native-pager-view": "6.2.3",
|
|
61
|
+
"react-native-webview": "13.6.4",
|
|
62
|
+
"react-native-vector-icons": "10.0.3",
|
|
62
63
|
"@react-navigation/drawer": "6.6.3",
|
|
63
|
-
"react-native-screens": "3.
|
|
64
|
-
"react-native-svg-transformer": "1.
|
|
65
|
-
"lottie-react-native": "5.1
|
|
66
|
-
"react-lottie-player": "
|
|
67
|
-
"expo-linear-gradient": "12.
|
|
64
|
+
"react-native-screens": "3.29.0",
|
|
65
|
+
"react-native-svg-transformer": "1.3.0",
|
|
66
|
+
"lottie-react-native": "6.5.1",
|
|
67
|
+
"react-lottie-player": "2.0.0",
|
|
68
|
+
"expo-linear-gradient": "12.7.2",
|
|
68
69
|
"setimmediate": "1.0.5",
|
|
69
70
|
"react-native-restart": "0.0.27",
|
|
70
|
-
"@expo/webpack-config": "
|
|
71
|
+
"@expo/webpack-config": "19.0.1",
|
|
71
72
|
"@babel/core": "7.20.2",
|
|
72
|
-
"@babel/standalone": "
|
|
73
|
+
"@babel/standalone": "7.23.10",
|
|
73
74
|
"@babel/plugin-syntax-jsx": "7.21.4",
|
|
74
75
|
"victory": "^36.5.3"
|
|
75
76
|
},
|
|
@@ -80,16 +81,12 @@
|
|
|
80
81
|
"esbuild": "0.15.15",
|
|
81
82
|
"esbuild-plugin-resolve": "1.0.3",
|
|
82
83
|
"fs-extra": "10.0.0",
|
|
83
|
-
"
|
|
84
|
+
"@babel/plugin-proposal-export-namespace-from": "7.18.9",
|
|
84
85
|
"babel-plugin-transform-remove-console": "6.9.4",
|
|
85
86
|
"@babel/plugin-proposal-optional-chaining": "7.21.0",
|
|
86
87
|
"@babel/plugin-proposal-nullish-coalescing-operator": "7.18.6",
|
|
87
|
-
"@types/babel__standalone": "
|
|
88
|
+
"@types/babel__standalone": "7.1.7",
|
|
88
89
|
"@expo/metro-config": "^0.7.1"
|
|
89
90
|
},
|
|
90
|
-
"resolutions": {
|
|
91
|
-
"react-error-overlay": "6.0.9",
|
|
92
|
-
"react-native-reanimated": "3.4.1"
|
|
93
|
-
},
|
|
94
91
|
"private": true
|
|
95
92
|
}
|
|
@@ -0,0 +1,303 @@
|
|
|
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 { I18nManager, InteractionManager, Keyboard, Platform, StatusBar, StyleSheet, View } from 'react-native';
|
|
4
|
+
import { PanGestureHandler, State as GestureState } from 'react-native-gesture-handler';
|
|
5
|
+
import Animated, { interpolate, runOnJS, useAnimatedGestureHandler, useAnimatedStyle, useDerivedValue, useSharedValue, withSpring } from 'react-native-reanimated';
|
|
6
|
+
import DrawerProgressContext from '../../utils/DrawerProgressContext';
|
|
7
|
+
import Overlay from './Overlay';
|
|
8
|
+
const SWIPE_DISTANCE_MINIMUM = 5;
|
|
9
|
+
const DEFAULT_DRAWER_WIDTH = '80%';
|
|
10
|
+
const minmax = (value, start, end) => {
|
|
11
|
+
'worklet';
|
|
12
|
+
|
|
13
|
+
return Math.min(Math.max(value, start), end);
|
|
14
|
+
};
|
|
15
|
+
export default function Drawer(_ref) {
|
|
16
|
+
let {
|
|
17
|
+
dimensions,
|
|
18
|
+
drawerPosition,
|
|
19
|
+
drawerStyle,
|
|
20
|
+
drawerType,
|
|
21
|
+
gestureHandlerProps,
|
|
22
|
+
hideStatusBarOnOpen,
|
|
23
|
+
keyboardDismissMode,
|
|
24
|
+
onClose,
|
|
25
|
+
onOpen,
|
|
26
|
+
open,
|
|
27
|
+
overlayStyle,
|
|
28
|
+
renderDrawerContent,
|
|
29
|
+
renderSceneContent,
|
|
30
|
+
statusBarAnimation,
|
|
31
|
+
swipeDistanceThreshold,
|
|
32
|
+
swipeEdgeWidth,
|
|
33
|
+
swipeEnabled,
|
|
34
|
+
swipeVelocityThreshold,
|
|
35
|
+
overlayAccessibilityLabel
|
|
36
|
+
} = _ref;
|
|
37
|
+
const getDrawerWidth = () => {
|
|
38
|
+
const {
|
|
39
|
+
width = DEFAULT_DRAWER_WIDTH
|
|
40
|
+
} = StyleSheet.flatten(drawerStyle) || {};
|
|
41
|
+
if (typeof width === 'string' && width.endsWith('%')) {
|
|
42
|
+
// Try to calculate width if a percentage is given
|
|
43
|
+
const percentage = Number(width.replace(/%$/, ''));
|
|
44
|
+
if (Number.isFinite(percentage)) {
|
|
45
|
+
return dimensions.width * (percentage / 100);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return typeof width === 'number' ? width : 0;
|
|
49
|
+
};
|
|
50
|
+
const drawerWidth = getDrawerWidth();
|
|
51
|
+
const isOpen = drawerType === 'permanent' ? true : open;
|
|
52
|
+
const isRight = drawerPosition === 'right';
|
|
53
|
+
const getDrawerTranslationX = React.useCallback(open => {
|
|
54
|
+
'worklet';
|
|
55
|
+
|
|
56
|
+
if (drawerPosition === 'left') {
|
|
57
|
+
return open ? 0 : -drawerWidth;
|
|
58
|
+
}
|
|
59
|
+
return open ? 0 : drawerWidth;
|
|
60
|
+
}, [drawerPosition, drawerWidth]);
|
|
61
|
+
const hideStatusBar = React.useCallback(hide => {
|
|
62
|
+
if (hideStatusBarOnOpen) {
|
|
63
|
+
StatusBar.setHidden(hide, statusBarAnimation);
|
|
64
|
+
}
|
|
65
|
+
}, [hideStatusBarOnOpen, statusBarAnimation]);
|
|
66
|
+
React.useEffect(() => {
|
|
67
|
+
hideStatusBar(isOpen);
|
|
68
|
+
return () => hideStatusBar(false);
|
|
69
|
+
}, [isOpen, hideStatusBarOnOpen, statusBarAnimation, hideStatusBar]);
|
|
70
|
+
const interactionHandleRef = React.useRef(null);
|
|
71
|
+
const startInteraction = () => {
|
|
72
|
+
interactionHandleRef.current = InteractionManager.createInteractionHandle();
|
|
73
|
+
};
|
|
74
|
+
const endInteraction = () => {
|
|
75
|
+
if (interactionHandleRef.current != null) {
|
|
76
|
+
InteractionManager.clearInteractionHandle(interactionHandleRef.current);
|
|
77
|
+
interactionHandleRef.current = null;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
const hideKeyboard = () => {
|
|
81
|
+
if (keyboardDismissMode === 'on-drag') {
|
|
82
|
+
Keyboard.dismiss();
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
const onGestureStart = () => {
|
|
86
|
+
startInteraction();
|
|
87
|
+
hideKeyboard();
|
|
88
|
+
hideStatusBar(true);
|
|
89
|
+
};
|
|
90
|
+
const onGestureFinish = () => {
|
|
91
|
+
endInteraction();
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
// FIXME: Currently hitSlop is broken when on Android when drawer is on right
|
|
95
|
+
// https://github.com/software-mansion/react-native-gesture-handler/issues/569
|
|
96
|
+
const hitSlop = isRight ?
|
|
97
|
+
// Extend hitSlop to the side of the screen when drawer is closed
|
|
98
|
+
// This lets the user drag the drawer from the side of the screen
|
|
99
|
+
{
|
|
100
|
+
right: 0,
|
|
101
|
+
width: isOpen ? undefined : swipeEdgeWidth
|
|
102
|
+
} : {
|
|
103
|
+
left: 0,
|
|
104
|
+
width: isOpen ? undefined : swipeEdgeWidth
|
|
105
|
+
};
|
|
106
|
+
const touchStartX = useSharedValue(0);
|
|
107
|
+
const touchX = useSharedValue(0);
|
|
108
|
+
const translationX = useSharedValue(getDrawerTranslationX(open));
|
|
109
|
+
const gestureState = useSharedValue(GestureState.UNDETERMINED);
|
|
110
|
+
const toggleDrawer = React.useCallback(_ref2 => {
|
|
111
|
+
'worklet';
|
|
112
|
+
|
|
113
|
+
let {
|
|
114
|
+
open,
|
|
115
|
+
isUserInitiated,
|
|
116
|
+
velocity
|
|
117
|
+
} = _ref2;
|
|
118
|
+
const translateX = getDrawerTranslationX(open);
|
|
119
|
+
touchStartX.value = 0;
|
|
120
|
+
touchX.value = 0;
|
|
121
|
+
translationX.value = withSpring(translateX, {
|
|
122
|
+
velocity,
|
|
123
|
+
stiffness: 1000,
|
|
124
|
+
damping: 500,
|
|
125
|
+
mass: 3,
|
|
126
|
+
overshootClamping: true,
|
|
127
|
+
restDisplacementThreshold: 0.01,
|
|
128
|
+
restSpeedThreshold: 0.01
|
|
129
|
+
});
|
|
130
|
+
if (!isUserInitiated) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
if (open) {
|
|
134
|
+
runOnJS(onOpen)();
|
|
135
|
+
} else {
|
|
136
|
+
runOnJS(onClose)();
|
|
137
|
+
}
|
|
138
|
+
}, [getDrawerTranslationX, onClose, onOpen, touchStartX, touchX, translationX]);
|
|
139
|
+
React.useEffect(() => toggleDrawer({
|
|
140
|
+
open,
|
|
141
|
+
isUserInitiated: false
|
|
142
|
+
}), [open, toggleDrawer]);
|
|
143
|
+
const onGestureEvent = useAnimatedGestureHandler({
|
|
144
|
+
onStart: (event, ctx) => {
|
|
145
|
+
ctx.hasCalledOnStart = false;
|
|
146
|
+
ctx.startX = translationX.value;
|
|
147
|
+
gestureState.value = event.state;
|
|
148
|
+
touchStartX.value = event.x;
|
|
149
|
+
},
|
|
150
|
+
onActive: (event, ctx) => {
|
|
151
|
+
touchX.value = event.x;
|
|
152
|
+
translationX.value = ctx.startX + event.translationX;
|
|
153
|
+
gestureState.value = event.state;
|
|
154
|
+
|
|
155
|
+
// onStart will _always_ be called, even when the activation
|
|
156
|
+
// criteria isn't met yet. This makes sure onGestureStart is only
|
|
157
|
+
// called when the criteria is really met.
|
|
158
|
+
if (!ctx.hasCalledOnStart) {
|
|
159
|
+
ctx.hasCalledOnStart = true;
|
|
160
|
+
runOnJS(onGestureStart)();
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
onEnd: event => {
|
|
164
|
+
gestureState.value = event.state;
|
|
165
|
+
const nextOpen = Math.abs(event.translationX) > SWIPE_DISTANCE_MINIMUM && Math.abs(event.translationX) > swipeVelocityThreshold || Math.abs(event.translationX) > swipeDistanceThreshold ? drawerPosition === 'left' ?
|
|
166
|
+
// If swiped to right, open the drawer, otherwise close it
|
|
167
|
+
(event.velocityX === 0 ? event.translationX : event.velocityX) > 0 :
|
|
168
|
+
// If swiped to left, open the drawer, otherwise close it
|
|
169
|
+
(event.velocityX === 0 ? event.translationX : event.velocityX) < 0 : open;
|
|
170
|
+
toggleDrawer({
|
|
171
|
+
open: nextOpen,
|
|
172
|
+
isUserInitiated: true,
|
|
173
|
+
velocity: event.velocityX
|
|
174
|
+
});
|
|
175
|
+
},
|
|
176
|
+
onFinish: () => {
|
|
177
|
+
runOnJS(onGestureFinish)();
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
const translateX = useDerivedValue(() => {
|
|
181
|
+
// Comment stolen from react-native-gesture-handler/DrawerLayout
|
|
182
|
+
//
|
|
183
|
+
// While closing the drawer when user starts gesture outside of its area (in greyed
|
|
184
|
+
// out part of the window), we want the drawer to follow only once finger reaches the
|
|
185
|
+
// edge of the drawer.
|
|
186
|
+
// E.g. on the diagram below drawer is illustrate by X signs and the greyed out area by
|
|
187
|
+
// dots. The touch gesture starts at '*' and moves left, touch path is indicated by
|
|
188
|
+
// an arrow pointing left
|
|
189
|
+
// 1) +---------------+ 2) +---------------+ 3) +---------------+ 4) +---------------+
|
|
190
|
+
// |XXXXXXXX|......| |XXXXXXXX|......| |XXXXXXXX|......| |XXXXX|.........|
|
|
191
|
+
// |XXXXXXXX|......| |XXXXXXXX|......| |XXXXXXXX|......| |XXXXX|.........|
|
|
192
|
+
// |XXXXXXXX|......| |XXXXXXXX|......| |XXXXXXXX|......| |XXXXX|.........|
|
|
193
|
+
// |XXXXXXXX|......| |XXXXXXXX|.<-*..| |XXXXXXXX|<--*..| |XXXXX|<-----*..|
|
|
194
|
+
// |XXXXXXXX|......| |XXXXXXXX|......| |XXXXXXXX|......| |XXXXX|.........|
|
|
195
|
+
// |XXXXXXXX|......| |XXXXXXXX|......| |XXXXXXXX|......| |XXXXX|.........|
|
|
196
|
+
// |XXXXXXXX|......| |XXXXXXXX|......| |XXXXXXXX|......| |XXXXX|.........|
|
|
197
|
+
// +---------------+ +---------------+ +---------------+ +---------------+
|
|
198
|
+
//
|
|
199
|
+
// For the above to work properly we define animated value that will keep start position
|
|
200
|
+
// of the gesture. Then we use that value to calculate how much we need to subtract from
|
|
201
|
+
// the translationX. If the gesture started on the greyed out area we take the distance from the
|
|
202
|
+
// edge of the drawer to the start position. Otherwise we don't subtract at all and the
|
|
203
|
+
// drawer be pulled back as soon as you start the pan.
|
|
204
|
+
//
|
|
205
|
+
// This is used only when drawerType is "front"
|
|
206
|
+
const touchDistance = drawerType === 'front' && gestureState.value === GestureState.ACTIVE ? minmax(drawerPosition === 'left' ? touchStartX.value - drawerWidth : dimensions.width - drawerWidth - touchStartX.value, 0, dimensions.width) : 0;
|
|
207
|
+
const translateX = drawerPosition === 'left' ? minmax(translationX.value + touchDistance, -drawerWidth, 0) : minmax(translationX.value - touchDistance, 0, drawerWidth);
|
|
208
|
+
return translateX;
|
|
209
|
+
}, [
|
|
210
|
+
drawerType,
|
|
211
|
+
gestureState,
|
|
212
|
+
minmax,
|
|
213
|
+
drawerPosition,
|
|
214
|
+
touchStartX,
|
|
215
|
+
drawerWidth,
|
|
216
|
+
translationX,
|
|
217
|
+
]);
|
|
218
|
+
const isRTL = I18nManager.getConstants().isRTL;
|
|
219
|
+
const drawerAnimatedStyle = useAnimatedStyle(() => {
|
|
220
|
+
const distanceFromEdge = dimensions.width - drawerWidth;
|
|
221
|
+
return {
|
|
222
|
+
transform: drawerType === 'permanent' ?
|
|
223
|
+
// Reanimated needs the property to be present, but it results in Browser bug
|
|
224
|
+
// https://bugs.chromium.org/p/chromium/issues/detail?id=20574
|
|
225
|
+
[] : [{
|
|
226
|
+
translateX:
|
|
227
|
+
// The drawer stays in place when `drawerType` is `back`
|
|
228
|
+
(drawerType === 'back' ? 0 : translateX.value) + (drawerPosition === 'left' ? isRTL ? -distanceFromEdge : 0 : isRTL ? 0 : distanceFromEdge)
|
|
229
|
+
}]
|
|
230
|
+
};
|
|
231
|
+
}, [ drawerWidth, drawerType, translateX, drawerPosition, isRTL]);
|
|
232
|
+
const contentAnimatedStyle = useAnimatedStyle(() => {
|
|
233
|
+
return {
|
|
234
|
+
transform: drawerType === 'permanent' ?
|
|
235
|
+
// Reanimated needs the property to be present, but it results in Browser bug
|
|
236
|
+
// https://bugs.chromium.org/p/chromium/issues/detail?id=20574
|
|
237
|
+
[] : [{
|
|
238
|
+
translateX:
|
|
239
|
+
// The screen content stays in place when `drawerType` is `front`
|
|
240
|
+
drawerType === 'front' ? 0 : translateX.value + drawerWidth * (drawerPosition === 'left' ? 1 : -1)
|
|
241
|
+
}]
|
|
242
|
+
};
|
|
243
|
+
}, [drawerType, translateX, drawerWidth, drawerPosition]);
|
|
244
|
+
const progress = useDerivedValue(() => {
|
|
245
|
+
return drawerType === 'permanent' ? 1 : interpolate(translateX.value, [getDrawerTranslationX(false), getDrawerTranslationX(true)], [0, 1]);
|
|
246
|
+
}, [drawerType, interpolate, translateX, getDrawerTranslationX]);
|
|
247
|
+
return /*#__PURE__*/React.createElement(DrawerProgressContext.Provider, {
|
|
248
|
+
value: progress
|
|
249
|
+
}, /*#__PURE__*/React.createElement(PanGestureHandler, _extends({
|
|
250
|
+
activeOffsetX: [-SWIPE_DISTANCE_MINIMUM, SWIPE_DISTANCE_MINIMUM],
|
|
251
|
+
failOffsetY: [-SWIPE_DISTANCE_MINIMUM, SWIPE_DISTANCE_MINIMUM],
|
|
252
|
+
hitSlop: hitSlop,
|
|
253
|
+
enabled: drawerType !== 'permanent' && swipeEnabled,
|
|
254
|
+
onGestureEvent: onGestureEvent
|
|
255
|
+
}, gestureHandlerProps), /*#__PURE__*/React.createElement(Animated.View, {
|
|
256
|
+
style: [styles.main, {
|
|
257
|
+
flexDirection: drawerType === 'permanent' && !isRight ? 'row-reverse' : 'row'
|
|
258
|
+
}]
|
|
259
|
+
}, /*#__PURE__*/React.createElement(Animated.View, {
|
|
260
|
+
style: [styles.content, contentAnimatedStyle]
|
|
261
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
262
|
+
accessibilityElementsHidden: isOpen && drawerType !== 'permanent',
|
|
263
|
+
importantForAccessibility: isOpen && drawerType !== 'permanent' ? 'no-hide-descendants' : 'auto',
|
|
264
|
+
style: styles.content
|
|
265
|
+
}, renderSceneContent()), drawerType !== 'permanent' ? /*#__PURE__*/React.createElement(Overlay, {
|
|
266
|
+
progress: progress,
|
|
267
|
+
onPress: () => toggleDrawer({
|
|
268
|
+
open: false,
|
|
269
|
+
isUserInitiated: true
|
|
270
|
+
}),
|
|
271
|
+
style: overlayStyle,
|
|
272
|
+
accessibilityLabel: overlayAccessibilityLabel
|
|
273
|
+
}) : null), /*#__PURE__*/React.createElement(Animated.View, {
|
|
274
|
+
removeClippedSubviews: Platform.OS !== 'ios',
|
|
275
|
+
style: [styles.container, {
|
|
276
|
+
position: drawerType === 'permanent' ? 'relative' : 'absolute',
|
|
277
|
+
zIndex: drawerType === 'back' ? -1 : 0
|
|
278
|
+
}, drawerAnimatedStyle, drawerStyle]
|
|
279
|
+
}, renderDrawerContent()))));
|
|
280
|
+
}
|
|
281
|
+
const styles = StyleSheet.create({
|
|
282
|
+
container: {
|
|
283
|
+
top: 0,
|
|
284
|
+
bottom: 0,
|
|
285
|
+
maxWidth: '100%',
|
|
286
|
+
width: DEFAULT_DRAWER_WIDTH
|
|
287
|
+
},
|
|
288
|
+
content: {
|
|
289
|
+
flex: 1
|
|
290
|
+
},
|
|
291
|
+
main: {
|
|
292
|
+
flex: 1,
|
|
293
|
+
...Platform.select({
|
|
294
|
+
// FIXME: We need to hide `overflowX` on Web so the translated content doesn't show offscreen.
|
|
295
|
+
// But adding `overflowX: 'hidden'` prevents content from collapsing the URL bar.
|
|
296
|
+
web: null,
|
|
297
|
+
default: {
|
|
298
|
+
overflow: 'hidden'
|
|
299
|
+
}
|
|
300
|
+
})
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
//# sourceMappingURL=Drawer.js.map
|
|
@@ -0,0 +1,60 @@
|
|
|
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, { useAnimatedProps, useAnimatedStyle } from 'react-native-reanimated';
|
|
5
|
+
const PROGRESS_EPSILON = 0.05;
|
|
6
|
+
const Overlay = /*#__PURE__*/React.forwardRef(function Overlay(_ref, ref) {
|
|
7
|
+
let {
|
|
8
|
+
progress,
|
|
9
|
+
onPress,
|
|
10
|
+
style,
|
|
11
|
+
accessibilityLabel = 'Close drawer',
|
|
12
|
+
...props
|
|
13
|
+
} = _ref;
|
|
14
|
+
const animatedStyle = useAnimatedStyle(() => {
|
|
15
|
+
return {
|
|
16
|
+
opacity: progress.value,
|
|
17
|
+
// We don't want the user to be able to press through the overlay when drawer is open
|
|
18
|
+
// We can send the overlay behind the screen to avoid it
|
|
19
|
+
zIndex: progress.value > PROGRESS_EPSILON ? 0 : -1
|
|
20
|
+
};
|
|
21
|
+
}, [progress, PROGRESS_EPSILON]);
|
|
22
|
+
const animatedProps = useAnimatedProps(() => {
|
|
23
|
+
const active = progress.value > PROGRESS_EPSILON;
|
|
24
|
+
return {
|
|
25
|
+
pointerEvents: active ? 'auto' : 'none',
|
|
26
|
+
accessibilityElementsHidden: !active,
|
|
27
|
+
importantForAccessibility: active ? 'auto' : 'no-hide-descendants'
|
|
28
|
+
};
|
|
29
|
+
}, [progress, PROGRESS_EPSILON]);
|
|
30
|
+
return /*#__PURE__*/React.createElement(Animated.View, _extends({}, props, {
|
|
31
|
+
ref: ref,
|
|
32
|
+
style: [styles.overlay, overlayStyle, animatedStyle, style],
|
|
33
|
+
animatedProps: animatedProps
|
|
34
|
+
}), /*#__PURE__*/React.createElement(Pressable, {
|
|
35
|
+
onPress: onPress,
|
|
36
|
+
style: styles.pressable,
|
|
37
|
+
accessibilityRole: "button",
|
|
38
|
+
accessibilityLabel: accessibilityLabel
|
|
39
|
+
}));
|
|
40
|
+
});
|
|
41
|
+
const overlayStyle = Platform.select({
|
|
42
|
+
web: {
|
|
43
|
+
// Disable touch highlight on mobile Safari.
|
|
44
|
+
// WebkitTapHighlightColor must be used outside of StyleSheet.create because react-native-web will omit the property.
|
|
45
|
+
WebkitTapHighlightColor: 'transparent'
|
|
46
|
+
},
|
|
47
|
+
default: {}
|
|
48
|
+
});
|
|
49
|
+
const styles = StyleSheet.create({
|
|
50
|
+
overlay: {
|
|
51
|
+
...StyleSheet.absoluteFillObject,
|
|
52
|
+
backgroundColor: 'rgba(0, 0, 0, 0.5)'
|
|
53
|
+
},
|
|
54
|
+
pressable: {
|
|
55
|
+
flex: 1,
|
|
56
|
+
pointerEvents: 'auto'
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
export default Overlay;
|
|
60
|
+
//# sourceMappingURL=Overlay.js.map
|
|
@@ -136,6 +136,10 @@ class EsBuilder {
|
|
|
136
136
|
);
|
|
137
137
|
}`;
|
|
138
138
|
});
|
|
139
|
+
const target = `${__dirname}/../node_modules/react-native-web/dist/cjs/exports/BackHandler/index.js`;
|
|
140
|
+
await readAndReplaceFileContent(target, content => {
|
|
141
|
+
return content.replace('console.error', '// console.error');
|
|
142
|
+
});
|
|
139
143
|
console.log('Patched react-native-web');
|
|
140
144
|
}
|
|
141
145
|
|
|
@@ -147,6 +151,101 @@ class EsBuilder {
|
|
|
147
151
|
}
|
|
148
152
|
}
|
|
149
153
|
|
|
154
|
+
async patchReactNativeAssetRegistry() {
|
|
155
|
+
const content = `
|
|
156
|
+
/**
|
|
157
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
158
|
+
*
|
|
159
|
+
* This source code is licensed under the MIT license found in the
|
|
160
|
+
* LICENSE file in the root directory of this source tree.
|
|
161
|
+
*
|
|
162
|
+
* @flow strict
|
|
163
|
+
* @format
|
|
164
|
+
*/
|
|
165
|
+
|
|
166
|
+
'use strict';
|
|
167
|
+
|
|
168
|
+
const assets = [];
|
|
169
|
+
|
|
170
|
+
function registerAsset(asset) {
|
|
171
|
+
// push returns new array length, so the first asset will
|
|
172
|
+
// get id 1 (not 0) to make the value truthy
|
|
173
|
+
return assets.push(asset);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function getAssetByID(assetId) {
|
|
177
|
+
return assets[assetId - 1];
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
module.exports = {registerAsset, getAssetByID};
|
|
181
|
+
|
|
182
|
+
`;
|
|
183
|
+
fs.writeFileSync(`${__dirname}/../node_modules/@react-native/assets-registry/registry.js`, content);
|
|
184
|
+
const expoAssetRegistry = `${__dirname}/../node_modules/expo-asset/node_modules/@react-native/assets-registry/registry.js`;
|
|
185
|
+
readAndReplaceFileContent(expoAssetRegistry, () => content);
|
|
186
|
+
console.log('Patched @react-native/assets-registry');
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
async patchBabelExpoPreset() {
|
|
190
|
+
const target = `${__dirname}/../node_modules/babel-preset-expo/build/index.js`;
|
|
191
|
+
await readAndReplaceFileContent(target, content => {
|
|
192
|
+
return content.replace(
|
|
193
|
+
`(0, common_1.hasModule)('react-native-reanimated') &&`,
|
|
194
|
+
`//(0, common_1.hasModule)('react-native-reanimated') &&`)
|
|
195
|
+
.replace(
|
|
196
|
+
`platformOptions.reanimated !== false && [require.resolve('react-native-reanimated/plugin')],`,
|
|
197
|
+
`//platformOptions.reanimated !== false && [require.resolve('react-native-reanimated/plugin')],`
|
|
198
|
+
)
|
|
199
|
+
});
|
|
200
|
+
console.log('Patched babel-expo-preset');
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
async patchUUID() {
|
|
204
|
+
const target = `${__dirname}/../node_modules/expo-modules-core/build/uuid/uuid.web.js`;
|
|
205
|
+
await readAndReplaceFileContent(target, content => {
|
|
206
|
+
return content.replace(`require('crypto')`, 'crypto');
|
|
207
|
+
});
|
|
208
|
+
console.log('Patched UUID.');
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
async patchExpoRootComponent() {
|
|
212
|
+
const target = `${__dirname}/../node_modules/expo/build/launch/registerRootComponent.js`;
|
|
213
|
+
await readAndReplaceFileContent(target, content => {
|
|
214
|
+
return content.replace(`export default`,
|
|
215
|
+
`
|
|
216
|
+
const process = {env: {
|
|
217
|
+
NODE_ENV: 'development',
|
|
218
|
+
EXPO_PUBLIC_USE_STATIC: '0'
|
|
219
|
+
}};
|
|
220
|
+
export default `);
|
|
221
|
+
});
|
|
222
|
+
console.log('Patched Expo Root Component.');
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
async patchReactNavigation() {
|
|
226
|
+
// https://github.com/react-navigation/react-navigation/pull/11496/files
|
|
227
|
+
fs.copyFileSync(
|
|
228
|
+
`${__dirname}/@react-navigation/drawer/6.6.3/lib/module/views/modern/Drawer.js`,
|
|
229
|
+
`${__dirname}/../node_modules/@react-navigation/drawer/lib/module/views/modern/Drawer.js`
|
|
230
|
+
);
|
|
231
|
+
fs.copyFileSync(
|
|
232
|
+
`${__dirname}/@react-navigation/drawer/6.6.3/lib/module/views/modern/Overlay.js`,
|
|
233
|
+
`${__dirname}/../node_modules/@react-navigation/drawer/lib/module/views/modern/Overlay.js`
|
|
234
|
+
);
|
|
235
|
+
console.log('Patched React Navigation.');
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
async patchReactNativeReanimated() {
|
|
239
|
+
await readAndReplaceFileContent(`${__dirname}/../node_modules/react-native-reanimated/lib/module/reanimated2/PlatformChecker.js`, (c) => {
|
|
240
|
+
return c.replace(
|
|
241
|
+
'!!process.env.JEST_WORKER_ID',
|
|
242
|
+
'false; // !!process.env.JEST_WORKER_ID'
|
|
243
|
+
)
|
|
244
|
+
});
|
|
245
|
+
console.log('Patched React Native Reanimated.');
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
|
|
150
249
|
buildLibraries() {
|
|
151
250
|
const promises = [{
|
|
152
251
|
name: 'expo-web-browser',
|
|
@@ -182,6 +281,12 @@ class EsBuilder {
|
|
|
182
281
|
.then(() => this.patchReactNativeWeb())
|
|
183
282
|
.then(() => this.patchReactNativeAssets())
|
|
184
283
|
.then(() => this.patchCamera())
|
|
284
|
+
.then(() => this.patchReactNativeAssetRegistry())
|
|
285
|
+
.then(() => this.patchBabelExpoPreset())
|
|
286
|
+
.then(() => this.patchUUID())
|
|
287
|
+
.then(() => this.patchExpoRootComponent())
|
|
288
|
+
.then(() => this.patchReactNavigation())
|
|
289
|
+
.then(() => this.patchReactNativeReanimated())
|
|
185
290
|
.then(() => {
|
|
186
291
|
console.log('*********** LIBRARIES ARE BUILT FOR ESBUILD **************');
|
|
187
292
|
}, (e) => {
|
|
@@ -212,7 +317,11 @@ class EsBuilder {
|
|
|
212
317
|
esmodules: true
|
|
213
318
|
},
|
|
214
319
|
sourceMaps: 'inline',
|
|
215
|
-
plugins: [
|
|
320
|
+
plugins: [
|
|
321
|
+
__dirname + '/../scripts/wm-babel.transform.plugin.js',
|
|
322
|
+
'@babel/plugin-proposal-export-namespace-from',
|
|
323
|
+
'react-native-reanimated/plugin',
|
|
324
|
+
]
|
|
216
325
|
}
|
|
217
326
|
}), resolve({
|
|
218
327
|
'victory-native': 'victory'
|
|
@@ -11,6 +11,7 @@ module.exports = (async () => {
|
|
|
11
11
|
];
|
|
12
12
|
config.resolver.disableHierarchicalLookup = true;
|
|
13
13
|
config.transformer = {
|
|
14
|
+
...config.transformer,
|
|
14
15
|
babelTransformerPath: require.resolve('react-native-svg-transformer'),
|
|
15
16
|
getTransformOptions: async () => ({
|
|
16
17
|
transform: {
|
|
@@ -20,6 +21,7 @@ module.exports = (async () => {
|
|
|
20
21
|
})
|
|
21
22
|
}
|
|
22
23
|
config.resolver = {
|
|
24
|
+
...config.resolver,
|
|
23
25
|
assetExts: config.resolver.assetExts.filter(ext => ext !== 'svg'),
|
|
24
26
|
sourceExts: [...config.resolver.sourceExts, 'svg']
|
|
25
27
|
}
|