@haroldtran/react-native-modals 0.0.5 → 0.0.7
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/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haroldtran/react-native-modals",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"description": "React Native Modals Library for IOS & Android.",
|
|
5
5
|
"main": "/src/index.tsx",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "jest",
|
|
8
|
-
"prebuild": "
|
|
8
|
+
"prebuild": "bun install && tsc --noEmit"
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
11
|
"src"
|
|
@@ -43,11 +43,7 @@ const styles = StyleSheet.create({
|
|
|
43
43
|
},
|
|
44
44
|
});
|
|
45
45
|
|
|
46
|
-
type ModalState =
|
|
47
|
-
| typeof MODAL_OPENING
|
|
48
|
-
| typeof MODAL_OPENED
|
|
49
|
-
| typeof MODAL_CLOSING
|
|
50
|
-
| typeof MODAL_CLOSED;
|
|
46
|
+
type ModalState = typeof MODAL_OPENING | typeof MODAL_OPENED | typeof MODAL_CLOSING | typeof MODAL_CLOSED;
|
|
51
47
|
|
|
52
48
|
type State = {
|
|
53
49
|
modalAnimation: Animation;
|
|
@@ -85,6 +81,7 @@ class BaseModal extends Component<ModalProps, State> {
|
|
|
85
81
|
onSwipingOut: () => {},
|
|
86
82
|
useNativeDriver: true,
|
|
87
83
|
useBlurView: false,
|
|
84
|
+
isDelay: false,
|
|
88
85
|
blurProps: {
|
|
89
86
|
blurType: "extraDark",
|
|
90
87
|
blurAmount: 20,
|
|
@@ -109,10 +106,7 @@ class BaseModal extends Component<ModalProps, State> {
|
|
|
109
106
|
if (this.props.visible) {
|
|
110
107
|
this.show();
|
|
111
108
|
}
|
|
112
|
-
this.backHandler = BackHandler.addEventListener(
|
|
113
|
-
HARDWARE_BACK_PRESS_EVENT,
|
|
114
|
-
this.onHardwareBackPress,
|
|
115
|
-
);
|
|
109
|
+
this.backHandler = BackHandler.addEventListener(HARDWARE_BACK_PRESS_EVENT, this.onHardwareBackPress);
|
|
116
110
|
}
|
|
117
111
|
|
|
118
112
|
componentDidUpdate(prevProps: ModalProps) {
|
|
@@ -129,8 +123,7 @@ class BaseModal extends Component<ModalProps, State> {
|
|
|
129
123
|
this.backHandler?.remove();
|
|
130
124
|
}
|
|
131
125
|
|
|
132
|
-
onHardwareBackPress = (): boolean =>
|
|
133
|
-
this.props.onHardwareBackPress ? this.props.onHardwareBackPress() : false;
|
|
126
|
+
onHardwareBackPress = (): boolean => (this.props.onHardwareBackPress ? this.props.onHardwareBackPress() : false);
|
|
134
127
|
|
|
135
128
|
get pointerEvents(): "auto" | "none" {
|
|
136
129
|
const { overlayPointerEvents } = this.props;
|
|
@@ -222,6 +215,7 @@ class BaseModal extends Component<ModalProps, State> {
|
|
|
222
215
|
swipeThreshold,
|
|
223
216
|
useBlurView,
|
|
224
217
|
blurProps,
|
|
218
|
+
isDelay,
|
|
225
219
|
} = this.props;
|
|
226
220
|
|
|
227
221
|
const overlayVisible = hasOverlay && [MODAL_OPENING, MODAL_OPENED].includes(modalState);
|
|
@@ -235,10 +229,7 @@ class BaseModal extends Component<ModalProps, State> {
|
|
|
235
229
|
hasFooter: Boolean(footer),
|
|
236
230
|
}}
|
|
237
231
|
>
|
|
238
|
-
<View
|
|
239
|
-
pointerEvents={this.isSwipingOut ? "none" : "auto"}
|
|
240
|
-
style={[styles.container, hidden]}
|
|
241
|
-
>
|
|
232
|
+
<View pointerEvents={this.isSwipingOut ? "none" : "auto"} style={[styles.container, hidden]}>
|
|
242
233
|
<DraggableView
|
|
243
234
|
style={StyleSheet.flatten([styles.draggableView, style])}
|
|
244
235
|
onMove={this.handleMove}
|
|
@@ -266,17 +257,9 @@ class BaseModal extends Component<ModalProps, State> {
|
|
|
266
257
|
blurProps={blurProps}
|
|
267
258
|
/>
|
|
268
259
|
<Animated.View style={pan.getLayout()} onLayout={onLayout}>
|
|
269
|
-
<Animated.View
|
|
270
|
-
style={[
|
|
271
|
-
styles.modal,
|
|
272
|
-
round,
|
|
273
|
-
this.modalSize,
|
|
274
|
-
modalStyle,
|
|
275
|
-
modalAnimation.getAnimations(),
|
|
276
|
-
]}
|
|
277
|
-
>
|
|
260
|
+
<Animated.View style={[styles.modal, round, this.modalSize, modalStyle, modalAnimation.getAnimations()]}>
|
|
278
261
|
{modalTitle}
|
|
279
|
-
{modalState === MODAL_OPENED
|
|
262
|
+
{isDelay ? (modalState === MODAL_OPENED ? children : null) : children}
|
|
280
263
|
{footer}
|
|
281
264
|
</Animated.View>
|
|
282
265
|
</Animated.View>
|
|
@@ -152,9 +152,10 @@ export default class DraggableView extends Component<Props> {
|
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
panResponder = PanResponder.create({
|
|
155
|
+
onStartShouldSetPanResponder: () => this.allowedDirections.length > 0,
|
|
155
156
|
onMoveShouldSetPanResponder: (evt, gestureState) =>
|
|
156
|
-
|
|
157
|
-
|
|
157
|
+
this.allowedDirections.length > 0 &&
|
|
158
|
+
(gestureState.dx !== 0 || gestureState.dy !== 0),
|
|
158
159
|
onPanResponderMove: (event: any, gestureState: any) => {
|
|
159
160
|
const isVerticalSwipe = (d: SwipeDirection | null) =>
|
|
160
161
|
["up", "down"].includes(d as string);
|