react-native-ui-lib 7.44.0 → 7.45.0-snapshot.7257
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/babel.config.js +12 -0
- package/index.js +1 -0
- package/lib/android/build.gradle +5 -5
- package/lib/android/src/main/java/com/wix/reactnativeuilib/UiLibPackageList.java +0 -2
- package/lib/android/src/main/java/com/wix/reactnativeuilib/highlighterview/HighlighterViewManager.java +31 -23
- package/lib/android/src/main/java/com/wix/reactnativeuilib/keyboardinput/utils/RuntimeUtils.java +1 -1
- package/lib/components/{HighlighterOverlayView.d.ts → HighlighterOverlayView/index.d.ts} +1 -1
- package/lib/components/HighlighterOverlayView/index.js +49 -0
- package/lib/components/{HighlighterOverlayView.web.d.ts → HighlighterOverlayView/index.web.d.ts} +1 -1
- package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/CustomKeyboardView.android.d.ts +5 -2
- package/lib/components/Keyboard/KeyboardAccessoryView/CustomKeyboardView/CustomKeyboardView.android.js +51 -0
- package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/CustomKeyboardView.ios.d.ts +1 -1
- package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/CustomKeyboardView.ios.js +3 -3
- package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView/CustomKeyboardView}/CustomKeyboardViewBase.d.ts +3 -0
- package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView/CustomKeyboardView}/CustomKeyboardViewBase.js +1 -1
- package/lib/components/Keyboard/{KeyboardInput/utils → KeyboardAccessoryView/KeyboardRegistry/EventEmitterManager}/__tests__/EventEmitterManager.spec.js +1 -1
- package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView/KeyboardRegistry}/__tests__/KeyboardRegistry.spec.js +1 -1
- package/lib/components/Keyboard/{KeyboardInput/KeyboardRegistry.d.ts → KeyboardAccessoryView/KeyboardRegistry/index.d.ts} +1 -1
- package/lib/components/Keyboard/{KeyboardInput/KeyboardRegistry.js → KeyboardAccessoryView/KeyboardRegistry/index.js} +1 -1
- package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView/KeyboardRegistry}/keyboardRegistry.api.json +9 -9
- package/lib/components/Keyboard/KeyboardAccessoryView/KeyboardUtils/index.d.ts +26 -0
- package/lib/components/Keyboard/KeyboardAccessoryView/KeyboardUtils/index.js +91 -0
- package/lib/components/Keyboard/{KeyboardInput/KeyboardAccessoryView.d.ts → KeyboardAccessoryView/index.d.ts} +11 -1
- package/lib/components/Keyboard/{KeyboardInput/KeyboardAccessoryView.js → KeyboardAccessoryView/index.js} +31 -5
- package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/keyboardAccessoryView.api.json +5 -5
- package/lib/components/Keyboard/{KeyboardTracking/KeyboardAwareInsetsView.d.ts → KeyboardAwareInsetsView/index.d.ts} +1 -1
- package/lib/components/Keyboard/{KeyboardTracking/KeyboardAwareInsetsView.js → KeyboardAwareInsetsView/index.js} +1 -1
- package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/KeyboardTrackingView.ios.d.ts +1 -4
- package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/KeyboardTrackingView.ios.js +5 -8
- package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/index.d.ts +2 -2
- package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/keyboardTrackingView.api.json +11 -20
- package/lib/components/Keyboard/index.d.ts +6 -6
- package/lib/components/Keyboard/index.js +6 -6
- package/lib/components/SafeArea/SafeAreaInsetsManager.d.ts +21 -7
- package/lib/components/SafeArea/SafeAreaInsetsManager.js +95 -31
- package/lib/components/SafeArea/SafeAreaSpacerView.d.ts +2 -2
- package/lib/components/SafeArea/SafeAreaSpacerView.js +63 -9
- package/lib/components/SafeArea/__tests__/SafeAreaInsetsManager.spec.js +274 -0
- package/lib/components/SafeArea/index.d.ts +10 -0
- package/lib/components/SafeArea/index.js +11 -0
- package/lib/components/index.d.ts +1 -1
- package/lib/components/index.js +1 -1
- package/lib/ios/reactnativeuilib/keyboardtrackingview/KeyboardTrackingViewTempManager.m +45 -32
- package/lib/package.json +1 -1
- package/lib/react-native.config.js +1 -3
- package/metro.config.js +2 -2
- package/package.json +24 -24
- package/panView.d.ts +2 -0
- package/panView.js +1 -0
- package/react-native.config.js +1 -3
- package/src/commons/Constants.js +2 -5
- package/src/components/KeyboardAwareScrollView/KeyboardAwareBase.js +5 -1
- package/src/components/actionSheet/index.d.ts +2 -12
- package/src/components/actionSheet/index.js +3 -42
- package/src/components/avatar/index.js +1 -1
- package/src/components/badge/index.d.ts +107 -47
- package/src/components/button/button.api.json +1 -1
- package/src/components/button/index.d.ts +53 -23
- package/src/components/button/types.d.ts +0 -1
- package/src/components/carousel/index.js +6 -1
- package/src/components/colorPicker/ColorPickerDialog.d.ts +1 -1
- package/src/components/colorPicker/ColorPickerDialog.js +1 -1
- package/src/components/dateTimePicker/index.d.ts +186 -5
- package/src/components/dateTimePicker/index.js +1 -2
- package/src/components/dialog/dialog.api.json +31 -37
- package/src/{incubator → components}/dialog/dialogHeader.api.json +2 -2
- package/src/components/dialog/index.d.ts +13 -105
- package/src/components/dialog/index.js +204 -212
- package/src/{incubator → components}/dialog/types.d.ts +0 -19
- package/src/{incubator → components}/dialog/types.js +1 -3
- package/src/{incubator → components}/dialog/useDialogContent.d.ts +1 -1
- package/src/components/drawer/Swipeable.js +1 -2
- package/src/components/drawer/index.js +31 -25
- package/src/components/fadedScrollView/index.js +7 -2
- package/src/components/featureHighlight/index.d.ts +1 -1
- package/src/components/index.js +0 -19
- package/src/components/modal/index.d.ts +5 -0
- package/src/components/modal/index.js +14 -10
- package/src/components/modal/modal.api.json +5 -0
- package/src/{incubator → components}/panView/index.d.ts +3 -3
- package/src/{incubator → components}/panView/index.js +4 -4
- package/src/{incubator → components}/panView/usePanGesture.d.ts +1 -1
- package/src/components/picker/Picker.driver.new.d.ts +2 -2
- package/src/components/picker/Picker.driver.new.js +3 -3
- package/src/components/picker/PickerItem.js +6 -20
- package/src/components/picker/PickerPresenter.d.ts +0 -1
- package/src/components/picker/PickerPresenter.js +1 -23
- package/src/components/picker/api/picker.api.json +0 -1
- package/src/components/picker/api/pickerItem.api.json +0 -5
- package/src/components/picker/helpers/useFieldType.d.ts +53 -23
- package/src/components/picker/helpers/usePickerLabel.d.ts +1 -1
- package/src/components/picker/helpers/usePickerLabel.js +2 -3
- package/src/components/picker/helpers/usePickerMigrationWarnings.d.ts +1 -1
- package/src/components/picker/helpers/usePickerMigrationWarnings.js +0 -12
- package/src/components/picker/helpers/usePickerSearch.d.ts +1 -1
- package/src/components/picker/helpers/usePickerSearch.js +4 -8
- package/src/components/picker/helpers/usePickerSelection.d.ts +1 -1
- package/src/components/picker/helpers/usePickerSelection.js +2 -10
- package/src/components/picker/index.js +4 -22
- package/src/components/picker/types.d.ts +1 -24
- package/src/components/segmentedControl/index.js +3 -3
- package/src/components/slider/GradientSlider.d.ts +1 -1
- package/src/components/sortableGridList/SortableItem.js +13 -4
- package/src/components/sortableList/SortableListItem.js +13 -4
- package/src/components/stackAggregator/index.js +16 -11
- package/src/components/textField/Input.js +0 -1
- package/src/components/textField/TextField.driver.new.d.ts +2 -2
- package/src/components/textField/TextField.driver.new.js +2 -2
- package/src/components/textField/presets/outline.d.ts +106 -46
- package/src/components/textField/presets/underline.d.ts +106 -46
- package/src/components/textField/usePreset.d.ts +72 -44
- package/src/{incubator/hooks/useHiddenLocation.web.d.ts → hooks/useHiddenLocation/index.d.ts} +1 -1
- package/src/{incubator/hooks/useHiddenLocation.d.ts → hooks/useHiddenLocation/index.web.d.ts} +1 -1
- package/src/incubator/expandableOverlay/ExpandableOverlay.driver.js +1 -1
- package/src/incubator/expandableOverlay/index.d.ts +42 -3
- package/src/incubator/expandableOverlay/index.js +1 -4
- package/src/incubator/index.d.ts +0 -2
- package/src/incubator/index.js +0 -2
- package/src/incubator/toast/index.js +1 -1
- package/src/index.d.ts +3 -10
- package/src/index.js +41 -160
- package/src/testkit/index.d.ts +1 -1
- package/src/testkit/index.js +1 -1
- package/src/testkit/new/Component.driver.d.ts +4 -1
- package/src/testkit/new/Component.driver.js +3 -3
- package/lib/android/src/main/java/com/wix/reactnativeuilib/highlighterview/ReactHacks.java +0 -30
- package/lib/android/src/main/java/com/wix/reactnativeuilib/highlighterview/ReflectionUtils.java +0 -34
- package/lib/android/src/main/java/com/wix/reactnativeuilib/textinput/DefaultKeyListener.java +0 -33
- package/lib/android/src/main/java/com/wix/reactnativeuilib/textinput/KeyListenerProxy.java +0 -53
- package/lib/android/src/main/java/com/wix/reactnativeuilib/textinput/TextInputDelKeyHandlerModule.java +0 -54
- package/lib/android/src/main/java/com/wix/reactnativeuilib/textinput/TextInputDelKeyHandlerPackage.java +0 -28
- package/lib/android/src/main/java/com/wix/reactnativeuilib/textinput/ViewUtils.java +0 -36
- package/lib/components/HighlighterOverlayView.js +0 -40
- package/lib/components/Keyboard/KeyboardInput/CustomKeyboardView/CustomKeyboardView.android.js +0 -28
- package/lib/components/Keyboard/KeyboardInput/utils/KeyboardUtils.d.ts +0 -11
- package/lib/components/Keyboard/KeyboardInput/utils/KeyboardUtils.js +0 -17
- package/panningViews.d.ts +0 -2
- package/panningViews.js +0 -1
- package/sharedTransition.d.ts +0 -2
- package/sharedTransition.js +0 -1
- package/src/components/dialog/DialogDismissibleView.d.ts +0 -34
- package/src/components/dialog/DialogDismissibleView.js +0 -184
- package/src/components/dialog/OverlayFadingBackground.d.ts +0 -14
- package/src/components/dialog/OverlayFadingBackground.js +0 -45
- package/src/components/panningViews/asPanViewConsumer.d.ts +0 -3
- package/src/components/panningViews/asPanViewConsumer.js +0 -16
- package/src/components/panningViews/panDismissibleView.d.ts +0 -51
- package/src/components/panningViews/panDismissibleView.js +0 -350
- package/src/components/panningViews/panGestureView.d.ts +0 -23
- package/src/components/panningViews/panGestureView.js +0 -156
- package/src/components/panningViews/panListenerView.d.ts +0 -66
- package/src/components/panningViews/panListenerView.js +0 -155
- package/src/components/panningViews/panResponderView.d.ts +0 -19
- package/src/components/panningViews/panResponderView.js +0 -79
- package/src/components/panningViews/panningContext.d.ts +0 -3
- package/src/components/panningViews/panningContext.js +0 -4
- package/src/components/panningViews/panningProvider.d.ts +0 -73
- package/src/components/panningViews/panningProvider.js +0 -101
- package/src/components/sharedTransition/ShareTransitionContext.js +0 -3
- package/src/components/sharedTransition/SharedArea.js +0 -153
- package/src/components/sharedTransition/SourceElement.js +0 -44
- package/src/components/sharedTransition/TargetElement.js +0 -38
- package/src/components/sharedTransition/index.js +0 -9
- package/src/incubator/dialog/dialog.api.json +0 -54
- package/src/incubator/dialog/index.d.ts +0 -15
- package/src/incubator/dialog/index.js +0 -218
- /package/lib/components/{HighlighterOverlayView.web.js → HighlighterOverlayView/index.web.js} +0 -0
- /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/index.d.ts +0 -0
- /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/index.js +0 -0
- /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/index.web.d.ts +0 -0
- /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/index.web.js +0 -0
- /package/lib/components/Keyboard/{KeyboardInput/utils/EventEmitterManager.d.ts → KeyboardAccessoryView/KeyboardRegistry/EventEmitterManager/index.d.ts} +0 -0
- /package/lib/components/Keyboard/{KeyboardInput/utils/EventEmitterManager.js → KeyboardAccessoryView/KeyboardRegistry/EventEmitterManager/index.js} +0 -0
- /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/TextInputKeyboardManager/TextInputKeyboardManager.android.d.ts +0 -0
- /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/TextInputKeyboardManager/TextInputKeyboardManager.android.js +0 -0
- /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/TextInputKeyboardManager/TextInputKeyboardManager.ios.d.ts +0 -0
- /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/TextInputKeyboardManager/TextInputKeyboardManager.ios.js +0 -0
- /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/TextInputKeyboardManager/index.d.ts +0 -0
- /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/TextInputKeyboardManager/index.js +0 -0
- /package/lib/components/Keyboard/{KeyboardTracking → KeyboardAwareInsetsView}/keyboardAwareInsetsView.api.json +0 -0
- /package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/KeyboardTrackingView.android.d.ts +0 -0
- /package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/KeyboardTrackingView.android.js +0 -0
- /package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/index.js +0 -0
- /package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/index.web.d.ts +0 -0
- /package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/index.web.js +0 -0
- /package/src/{incubator → components}/dialog/Dialog.driver.new.d.ts +0 -0
- /package/src/{incubator → components}/dialog/Dialog.driver.new.js +0 -0
- /package/src/{incubator → components}/dialog/DialogHeader.d.ts +0 -0
- /package/src/{incubator → components}/dialog/DialogHeader.js +0 -0
- /package/src/{incubator → components}/dialog/useDialogContent.js +0 -0
- /package/src/{incubator → components}/panView/panningUtil.d.ts +0 -0
- /package/src/{incubator → components}/panView/panningUtil.js +0 -0
- /package/src/{incubator → components}/panView/usePanGesture.js +0 -0
- /package/src/{incubator/hooks/useHiddenLocation.js → hooks/useHiddenLocation/index.js} +0 -0
- /package/src/{incubator/hooks/useHiddenLocation.web.js → hooks/useHiddenLocation/index.web.js} +0 -0
|
@@ -1,350 +0,0 @@
|
|
|
1
|
-
import _isUndefined from "lodash/isUndefined";
|
|
2
|
-
import _get from "lodash/get";
|
|
3
|
-
import _noop from "lodash/noop";
|
|
4
|
-
import React, { PureComponent } from 'react';
|
|
5
|
-
import { Animated } from 'react-native';
|
|
6
|
-
import { Constants } from "../../commons/new";
|
|
7
|
-
import asPanViewConsumer from "./asPanViewConsumer";
|
|
8
|
-
import PanningProvider from "./panningProvider";
|
|
9
|
-
const DEFAULT_DIRECTIONS = [PanningProvider.Directions.UP, PanningProvider.Directions.DOWN, PanningProvider.Directions.LEFT, PanningProvider.Directions.RIGHT];
|
|
10
|
-
const DEFAULT_SPEED = 20;
|
|
11
|
-
const DEFAULT_BOUNCINESS = 6;
|
|
12
|
-
const DEFAULT_DISMISS_ANIMATION_DURATION = 280;
|
|
13
|
-
const DEFAULT_ANIMATION_OPTIONS = {
|
|
14
|
-
speed: DEFAULT_SPEED,
|
|
15
|
-
bounciness: DEFAULT_BOUNCINESS,
|
|
16
|
-
duration: DEFAULT_DISMISS_ANIMATION_DURATION
|
|
17
|
-
};
|
|
18
|
-
const MAXIMUM_DRAGS_AFTER_SWIPE = 2;
|
|
19
|
-
/**
|
|
20
|
-
* @description: PanDismissibleView component created to making listening to swipe and drag events easier,
|
|
21
|
-
* @notes: Has to be used as a child of a PanningProvider that also has a PanListenerView.
|
|
22
|
-
* The PanListenerView is the one that sends the drag\swipe events.
|
|
23
|
-
* @gif: https://github.com/wix/react-native-ui-lib/blob/master/demo/showcase/PanDismissibleView/PanDismissibleView.gif?raw=true
|
|
24
|
-
*/
|
|
25
|
-
class PanDismissibleView extends PureComponent {
|
|
26
|
-
static displayName = 'IGNORE';
|
|
27
|
-
static defaultProps = {
|
|
28
|
-
directions: DEFAULT_DIRECTIONS,
|
|
29
|
-
animationOptions: DEFAULT_ANIMATION_OPTIONS,
|
|
30
|
-
onDismiss: _noop,
|
|
31
|
-
allowDiagonalDismiss: false
|
|
32
|
-
};
|
|
33
|
-
shouldDismissAfterReset = false;
|
|
34
|
-
ref = React.createRef();
|
|
35
|
-
animTranslateX = new Animated.Value(0);
|
|
36
|
-
animTranslateY = new Animated.Value(0);
|
|
37
|
-
left = 0;
|
|
38
|
-
top = 0;
|
|
39
|
-
width = 0;
|
|
40
|
-
height = 0;
|
|
41
|
-
thresholdX = 0;
|
|
42
|
-
thresholdY = 0;
|
|
43
|
-
swipe = {};
|
|
44
|
-
counter = 0;
|
|
45
|
-
constructor(props) {
|
|
46
|
-
super(props);
|
|
47
|
-
this.state = {
|
|
48
|
-
isAnimating: false
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
componentDidUpdate(prevProps) {
|
|
52
|
-
const {
|
|
53
|
-
isAnimating
|
|
54
|
-
} = this.state;
|
|
55
|
-
const {
|
|
56
|
-
isPanning,
|
|
57
|
-
dragDeltas,
|
|
58
|
-
swipeDirections
|
|
59
|
-
} = this.props.context;
|
|
60
|
-
const {
|
|
61
|
-
isPanning: prevIsPanning,
|
|
62
|
-
dragDeltas: prevDragDeltas,
|
|
63
|
-
swipeDirections: prevSwipeDirections
|
|
64
|
-
} = prevProps.context;
|
|
65
|
-
if (isPanning !== prevIsPanning) {
|
|
66
|
-
if (isPanning && !isAnimating) {
|
|
67
|
-
// do not start a new pan if we're still animating
|
|
68
|
-
this.onPanStart();
|
|
69
|
-
} else {
|
|
70
|
-
this.onPanEnd();
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
if (isPanning && (dragDeltas.x || dragDeltas.y) && (dragDeltas.x !== prevDragDeltas.x || dragDeltas.y !== prevDragDeltas.y)) {
|
|
74
|
-
this.onDrag(dragDeltas);
|
|
75
|
-
}
|
|
76
|
-
if (isPanning && (swipeDirections.x || swipeDirections.y) && (swipeDirections.x !== prevSwipeDirections.x || swipeDirections.y !== prevSwipeDirections.y)) {
|
|
77
|
-
this.onSwipe(swipeDirections);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
onLayout = event => {
|
|
81
|
-
if (this.height === 0) {
|
|
82
|
-
const layout = event.nativeEvent.layout;
|
|
83
|
-
const {
|
|
84
|
-
threshold
|
|
85
|
-
} = this.props;
|
|
86
|
-
this.height = layout.height;
|
|
87
|
-
this.thresholdY = _get(threshold, 'y', layout.height / 2);
|
|
88
|
-
this.width = layout.width;
|
|
89
|
-
this.thresholdX = _get(threshold, 'x', layout.width / 2);
|
|
90
|
-
this.initPositions();
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
initPositions = (extraDataForSetState, runAfterSetState) => {
|
|
94
|
-
this.setNativeProps(0, 0);
|
|
95
|
-
this.animTranslateX = new Animated.Value(0);
|
|
96
|
-
this.animTranslateY = new Animated.Value(0);
|
|
97
|
-
this.setState({
|
|
98
|
-
...extraDataForSetState
|
|
99
|
-
}, runAfterSetState);
|
|
100
|
-
};
|
|
101
|
-
onPanStart = () => {
|
|
102
|
-
this.swipe = {};
|
|
103
|
-
this.counter = 0;
|
|
104
|
-
};
|
|
105
|
-
onDrag = deltas => {
|
|
106
|
-
const left = deltas.x ? Math.round(deltas.x) : 0;
|
|
107
|
-
const top = deltas.y ? Math.round(deltas.y) : 0;
|
|
108
|
-
this.setNativeProps(left, top);
|
|
109
|
-
if (this.swipe.x || this.swipe.y) {
|
|
110
|
-
if (this.counter < MAXIMUM_DRAGS_AFTER_SWIPE) {
|
|
111
|
-
this.counter += 1;
|
|
112
|
-
} else {
|
|
113
|
-
this.swipe = {};
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
setNativeProps = (left, top) => {
|
|
118
|
-
if (this.ref.current) {
|
|
119
|
-
this.ref.current?.setNativeProps?.({
|
|
120
|
-
style: {
|
|
121
|
-
left,
|
|
122
|
-
top
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
this.left = left;
|
|
126
|
-
this.top = top;
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
onSwipe = swipeDirections => {
|
|
130
|
-
this.swipe = swipeDirections;
|
|
131
|
-
};
|
|
132
|
-
onPanEnd = () => {
|
|
133
|
-
const {
|
|
134
|
-
directions = DEFAULT_DIRECTIONS
|
|
135
|
-
} = this.props;
|
|
136
|
-
if (this.swipe.x || this.swipe.y) {
|
|
137
|
-
const {
|
|
138
|
-
isRight,
|
|
139
|
-
isDown
|
|
140
|
-
} = this.getDismissAnimationDirection();
|
|
141
|
-
this._animateDismiss(isRight, isDown);
|
|
142
|
-
} else {
|
|
143
|
-
const endValue = {
|
|
144
|
-
x: Math.round(this.left),
|
|
145
|
-
y: Math.round(this.top)
|
|
146
|
-
};
|
|
147
|
-
if (directions.includes(PanningProvider.Directions.LEFT) && endValue.x <= -this.thresholdX || directions.includes(PanningProvider.Directions.RIGHT) && endValue.x >= this.thresholdX || directions.includes(PanningProvider.Directions.UP) && endValue.y <= -this.thresholdY || directions.includes(PanningProvider.Directions.DOWN) && endValue.y >= this.thresholdY) {
|
|
148
|
-
const {
|
|
149
|
-
isRight,
|
|
150
|
-
isDown
|
|
151
|
-
} = this.getDismissAnimationDirection();
|
|
152
|
-
this._animateDismiss(isRight, isDown);
|
|
153
|
-
} else {
|
|
154
|
-
this.resetPosition();
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
resetPosition = () => {
|
|
159
|
-
const {
|
|
160
|
-
animationOptions
|
|
161
|
-
} = this.props;
|
|
162
|
-
const {
|
|
163
|
-
speed,
|
|
164
|
-
bounciness
|
|
165
|
-
} = animationOptions || DEFAULT_ANIMATION_OPTIONS;
|
|
166
|
-
const toX = -this.left;
|
|
167
|
-
const toY = -this.top;
|
|
168
|
-
const animations = [];
|
|
169
|
-
if (!_isUndefined(toX)) {
|
|
170
|
-
animations.push(Animated.spring(this.animTranslateX, {
|
|
171
|
-
toValue: Math.round(toX),
|
|
172
|
-
useNativeDriver: true,
|
|
173
|
-
speed,
|
|
174
|
-
bounciness
|
|
175
|
-
}));
|
|
176
|
-
}
|
|
177
|
-
if (!_isUndefined(toY)) {
|
|
178
|
-
animations.push(Animated.spring(this.animTranslateY, {
|
|
179
|
-
toValue: Math.round(toY),
|
|
180
|
-
useNativeDriver: true,
|
|
181
|
-
speed,
|
|
182
|
-
bounciness
|
|
183
|
-
}));
|
|
184
|
-
}
|
|
185
|
-
this.setState({
|
|
186
|
-
isAnimating: true
|
|
187
|
-
}, () => {
|
|
188
|
-
Animated.parallel(animations).start(this.onResetPositionFinished);
|
|
189
|
-
});
|
|
190
|
-
};
|
|
191
|
-
onResetPositionFinished = () => {
|
|
192
|
-
const runAfterSetState = this.shouldDismissAfterReset ? this.animateDismiss : undefined;
|
|
193
|
-
this.shouldDismissAfterReset = false;
|
|
194
|
-
this.initPositions({
|
|
195
|
-
isAnimating: false
|
|
196
|
-
}, runAfterSetState);
|
|
197
|
-
};
|
|
198
|
-
getDismissAnimationDirection = () => {
|
|
199
|
-
const {
|
|
200
|
-
allowDiagonalDismiss
|
|
201
|
-
} = this.props;
|
|
202
|
-
const {
|
|
203
|
-
swipeDirections,
|
|
204
|
-
swipeVelocities,
|
|
205
|
-
dragDirections,
|
|
206
|
-
dragDeltas
|
|
207
|
-
} = this.props.context;
|
|
208
|
-
const hasHorizontalSwipe = !_isUndefined(swipeDirections.x);
|
|
209
|
-
const hasVerticalSwipe = !_isUndefined(swipeDirections.y);
|
|
210
|
-
let isRight;
|
|
211
|
-
let isDown;
|
|
212
|
-
if (hasHorizontalSwipe || hasVerticalSwipe) {
|
|
213
|
-
if (!allowDiagonalDismiss && hasHorizontalSwipe && hasVerticalSwipe) {
|
|
214
|
-
// @ts-ignore
|
|
215
|
-
if (Math.abs(swipeVelocities.y) > Math.abs(swipeVelocities.x)) {
|
|
216
|
-
isDown = swipeDirections.y === PanningProvider.Directions.DOWN;
|
|
217
|
-
} else {
|
|
218
|
-
isRight = swipeDirections.x === PanningProvider.Directions.RIGHT;
|
|
219
|
-
}
|
|
220
|
-
return {
|
|
221
|
-
isRight,
|
|
222
|
-
isDown
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
if (hasHorizontalSwipe) {
|
|
226
|
-
isRight = swipeDirections.x === PanningProvider.Directions.RIGHT;
|
|
227
|
-
}
|
|
228
|
-
if (hasVerticalSwipe) {
|
|
229
|
-
isDown = swipeDirections.y === PanningProvider.Directions.DOWN;
|
|
230
|
-
}
|
|
231
|
-
} else {
|
|
232
|
-
// got here from a drag beyond threshold
|
|
233
|
-
const hasHorizontalDrag = !_isUndefined(dragDirections.x);
|
|
234
|
-
const hasVerticalDrag = !_isUndefined(dragDirections.y);
|
|
235
|
-
if (!allowDiagonalDismiss && hasHorizontalDrag && hasVerticalDrag) {
|
|
236
|
-
// @ts-ignore
|
|
237
|
-
if (Math.abs(dragDeltas.y) > Math.abs(dragDeltas.x)) {
|
|
238
|
-
isDown = dragDirections.y === PanningProvider.Directions.DOWN;
|
|
239
|
-
} else {
|
|
240
|
-
isRight = dragDirections.x === PanningProvider.Directions.RIGHT;
|
|
241
|
-
}
|
|
242
|
-
return {
|
|
243
|
-
isRight,
|
|
244
|
-
isDown
|
|
245
|
-
};
|
|
246
|
-
}
|
|
247
|
-
if (hasHorizontalDrag) {
|
|
248
|
-
isRight = dragDirections.x === PanningProvider.Directions.RIGHT;
|
|
249
|
-
}
|
|
250
|
-
if (hasVerticalDrag) {
|
|
251
|
-
isDown = dragDirections.y === PanningProvider.Directions.DOWN;
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
return {
|
|
255
|
-
isRight,
|
|
256
|
-
isDown
|
|
257
|
-
};
|
|
258
|
-
};
|
|
259
|
-
|
|
260
|
-
// Send undefined to not animate in the horizontal\vertical direction
|
|
261
|
-
// isRight === true --> animate to the right
|
|
262
|
-
// isRight === false --> animate to the left
|
|
263
|
-
// isDown === true --> animate to the bottom
|
|
264
|
-
// isDown === false --> animate to the top
|
|
265
|
-
animateDismiss = () => {
|
|
266
|
-
const {
|
|
267
|
-
isAnimating
|
|
268
|
-
} = this.state;
|
|
269
|
-
if (isAnimating) {
|
|
270
|
-
this.shouldDismissAfterReset = true;
|
|
271
|
-
} else {
|
|
272
|
-
const {
|
|
273
|
-
directions = []
|
|
274
|
-
} = this.props;
|
|
275
|
-
const hasUp = directions.includes(PanningProvider.Directions.UP);
|
|
276
|
-
const hasRight = directions.includes(PanningProvider.Directions.RIGHT);
|
|
277
|
-
const hasLeft = directions.includes(PanningProvider.Directions.LEFT);
|
|
278
|
-
const hasDown = !hasUp && !hasLeft && !hasRight; // default
|
|
279
|
-
const verticalDismiss = hasDown ? true : hasUp ? false : undefined;
|
|
280
|
-
const horizontalDismiss = hasRight ? true : hasLeft ? false : undefined;
|
|
281
|
-
this._animateDismiss(horizontalDismiss, verticalDismiss);
|
|
282
|
-
}
|
|
283
|
-
};
|
|
284
|
-
_animateDismiss = (isRight, isDown) => {
|
|
285
|
-
const {
|
|
286
|
-
animationOptions
|
|
287
|
-
} = this.props;
|
|
288
|
-
const {
|
|
289
|
-
duration
|
|
290
|
-
} = animationOptions || DEFAULT_ANIMATION_OPTIONS;
|
|
291
|
-
const animations = [];
|
|
292
|
-
let toX;
|
|
293
|
-
let toY;
|
|
294
|
-
if (!_isUndefined(isRight)) {
|
|
295
|
-
const maxSize = Constants.screenWidth + this.width;
|
|
296
|
-
toX = isRight ? maxSize : -maxSize;
|
|
297
|
-
}
|
|
298
|
-
if (!_isUndefined(isDown)) {
|
|
299
|
-
const maxSize = Constants.screenHeight + this.height;
|
|
300
|
-
toY = isDown ? maxSize : -maxSize;
|
|
301
|
-
}
|
|
302
|
-
if (!_isUndefined(toX)) {
|
|
303
|
-
animations.push(Animated.timing(this.animTranslateX, {
|
|
304
|
-
toValue: Math.round(toX),
|
|
305
|
-
useNativeDriver: true,
|
|
306
|
-
duration
|
|
307
|
-
}));
|
|
308
|
-
}
|
|
309
|
-
if (!_isUndefined(toY)) {
|
|
310
|
-
animations.push(Animated.timing(this.animTranslateY, {
|
|
311
|
-
toValue: Math.round(toY),
|
|
312
|
-
useNativeDriver: true,
|
|
313
|
-
duration
|
|
314
|
-
}));
|
|
315
|
-
}
|
|
316
|
-
this.setState({
|
|
317
|
-
isAnimating: true
|
|
318
|
-
}, () => {
|
|
319
|
-
Animated.parallel(animations).start(this.onDismissAnimationFinished);
|
|
320
|
-
});
|
|
321
|
-
};
|
|
322
|
-
onDismissAnimationFinished = ({
|
|
323
|
-
finished
|
|
324
|
-
}) => {
|
|
325
|
-
if (finished) {
|
|
326
|
-
this.props.onDismiss?.();
|
|
327
|
-
}
|
|
328
|
-
};
|
|
329
|
-
render() {
|
|
330
|
-
const {
|
|
331
|
-
style
|
|
332
|
-
} = this.props;
|
|
333
|
-
const {
|
|
334
|
-
isAnimating
|
|
335
|
-
} = this.state;
|
|
336
|
-
const transform = isAnimating ? [{
|
|
337
|
-
translateX: this.animTranslateX
|
|
338
|
-
}, {
|
|
339
|
-
translateY: this.animTranslateY
|
|
340
|
-
}] : [];
|
|
341
|
-
return <Animated.View
|
|
342
|
-
// @ts-ignore
|
|
343
|
-
ref={this.ref} style={[style, {
|
|
344
|
-
transform
|
|
345
|
-
}]} onLayout={this.onLayout}>
|
|
346
|
-
{this.props.children}
|
|
347
|
-
</Animated.View>;
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
export default asPanViewConsumer(PanDismissibleView);
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { StyleProp, ViewStyle } from 'react-native';
|
|
3
|
-
export declare enum GestureDirections {
|
|
4
|
-
UP = "up",
|
|
5
|
-
DOWN = "down"
|
|
6
|
-
}
|
|
7
|
-
export interface PanGestureViewProps {
|
|
8
|
-
/**
|
|
9
|
-
* Additional styling
|
|
10
|
-
*/
|
|
11
|
-
style?: StyleProp<ViewStyle>;
|
|
12
|
-
/**
|
|
13
|
-
* onDismiss callback
|
|
14
|
-
*/
|
|
15
|
-
onDismiss?: () => void;
|
|
16
|
-
/**
|
|
17
|
-
* The direction of the allowed pan (default is down)
|
|
18
|
-
*/
|
|
19
|
-
direction?: GestureDirections | `${GestureDirections}`;
|
|
20
|
-
children?: React.ReactNode;
|
|
21
|
-
}
|
|
22
|
-
declare const _default: React.ForwardRefExoticComponent<PanGestureViewProps & React.RefAttributes<any>>;
|
|
23
|
-
export default _default;
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import React, { Component } from 'react';
|
|
2
|
-
import { PanResponder, Animated } from 'react-native';
|
|
3
|
-
import { Constants, asBaseComponent } from "../../commons/new";
|
|
4
|
-
export let GestureDirections = /*#__PURE__*/function (GestureDirections) {
|
|
5
|
-
GestureDirections["UP"] = "up";
|
|
6
|
-
GestureDirections["DOWN"] = "down";
|
|
7
|
-
return GestureDirections;
|
|
8
|
-
}({});
|
|
9
|
-
const SWIPE_VELOCITY = 1.8;
|
|
10
|
-
const SPEED = 20;
|
|
11
|
-
const BOUNCINESS = 6;
|
|
12
|
-
/**
|
|
13
|
-
* @description: PanGestureView component for drag and swipe gestures (supports only vertical gestures at the moment)
|
|
14
|
-
*/
|
|
15
|
-
class PanGestureView extends Component {
|
|
16
|
-
static displayName = 'IGNORE';
|
|
17
|
-
static defaultProps = {
|
|
18
|
-
direction: GestureDirections.DOWN
|
|
19
|
-
};
|
|
20
|
-
static directions = GestureDirections;
|
|
21
|
-
constructor(props) {
|
|
22
|
-
super(props);
|
|
23
|
-
this.state = {
|
|
24
|
-
deltaY: new Animated.Value(0)
|
|
25
|
-
};
|
|
26
|
-
this.panResponder = PanResponder.create({
|
|
27
|
-
onMoveShouldSetPanResponder: this.handleMoveShouldSetPanResponder,
|
|
28
|
-
onPanResponderGrant: this.handlePanResponderGrant,
|
|
29
|
-
onPanResponderMove: this.handlePanResponderMove,
|
|
30
|
-
onPanResponderRelease: this.handlePanResponderEnd,
|
|
31
|
-
onPanResponderTerminate: this.handlePanResponderEnd
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
handleMoveShouldSetPanResponder = (_e, gestureState) => {
|
|
35
|
-
// return true if user is swiping, return false if it's a single click
|
|
36
|
-
const {
|
|
37
|
-
dy
|
|
38
|
-
} = gestureState;
|
|
39
|
-
return dy > 5 || dy < -5;
|
|
40
|
-
};
|
|
41
|
-
handlePanResponderGrant = () => {
|
|
42
|
-
this.swipe = false;
|
|
43
|
-
};
|
|
44
|
-
handlePanResponderMove = (_e, gestureState) => {
|
|
45
|
-
const {
|
|
46
|
-
direction
|
|
47
|
-
} = this.props;
|
|
48
|
-
let newValue = 0;
|
|
49
|
-
|
|
50
|
-
// VERTICAL
|
|
51
|
-
const up = direction === GestureDirections.UP;
|
|
52
|
-
const panDeltaY = gestureState.dy;
|
|
53
|
-
const panVelocityY = gestureState.vy;
|
|
54
|
-
if (Math.abs(panVelocityY) >= SWIPE_VELOCITY) {
|
|
55
|
-
if (up && panVelocityY < 0 || !up && panVelocityY > 0) {
|
|
56
|
-
// Swipe
|
|
57
|
-
this.swipe = true;
|
|
58
|
-
}
|
|
59
|
-
} else if (up && panDeltaY < 0 || !up && panDeltaY > 0) {
|
|
60
|
-
// Drag
|
|
61
|
-
newValue = panDeltaY;
|
|
62
|
-
this.animateDeltaY(Math.round(newValue));
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
handlePanResponderEnd = () => {
|
|
66
|
-
if (!this.swipe) {
|
|
67
|
-
const {
|
|
68
|
-
direction
|
|
69
|
-
} = this.props;
|
|
70
|
-
|
|
71
|
-
// VERTICAL
|
|
72
|
-
const up = direction === GestureDirections.UP;
|
|
73
|
-
const {
|
|
74
|
-
deltaY
|
|
75
|
-
} = this.state;
|
|
76
|
-
// @ts-ignore
|
|
77
|
-
const threshold = this.layout.height / 2;
|
|
78
|
-
// @ts-ignore
|
|
79
|
-
const endValue = Math.round(deltaY._value);
|
|
80
|
-
if (up && endValue <= -threshold || !up && endValue >= threshold) {
|
|
81
|
-
this.animateDismiss();
|
|
82
|
-
} else {
|
|
83
|
-
// back to initial position
|
|
84
|
-
this.animateDeltaY(0);
|
|
85
|
-
}
|
|
86
|
-
} else {
|
|
87
|
-
this.animateDismiss();
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
animateDeltaY(toValue) {
|
|
91
|
-
const {
|
|
92
|
-
deltaY
|
|
93
|
-
} = this.state;
|
|
94
|
-
Animated.spring(deltaY, {
|
|
95
|
-
toValue,
|
|
96
|
-
useNativeDriver: true,
|
|
97
|
-
speed: SPEED,
|
|
98
|
-
bounciness: BOUNCINESS
|
|
99
|
-
}).start();
|
|
100
|
-
}
|
|
101
|
-
animateDismiss() {
|
|
102
|
-
const {
|
|
103
|
-
direction
|
|
104
|
-
} = this.props;
|
|
105
|
-
|
|
106
|
-
// VERTICAL
|
|
107
|
-
const up = direction === GestureDirections.UP;
|
|
108
|
-
const {
|
|
109
|
-
deltaY
|
|
110
|
-
} = this.state;
|
|
111
|
-
// @ts-ignore
|
|
112
|
-
const newValue = up ? -this.layout.height - Constants.statusBarHeight : deltaY._value + Constants.screenHeight;
|
|
113
|
-
Animated.timing(deltaY, {
|
|
114
|
-
toValue: Math.round(newValue),
|
|
115
|
-
useNativeDriver: true,
|
|
116
|
-
duration: 280
|
|
117
|
-
}).start(this.onAnimatedFinished);
|
|
118
|
-
}
|
|
119
|
-
onAnimatedFinished = ({
|
|
120
|
-
finished
|
|
121
|
-
}) => {
|
|
122
|
-
if (finished) {
|
|
123
|
-
this.onDismiss();
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
onDismiss = () => {
|
|
127
|
-
this.initPositions();
|
|
128
|
-
this.props.onDismiss?.();
|
|
129
|
-
};
|
|
130
|
-
initPositions() {
|
|
131
|
-
this.setState({
|
|
132
|
-
deltaY: new Animated.Value(0)
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
onLayout = event => {
|
|
136
|
-
this.layout = event.nativeEvent.layout;
|
|
137
|
-
};
|
|
138
|
-
render() {
|
|
139
|
-
const {
|
|
140
|
-
style
|
|
141
|
-
} = this.props;
|
|
142
|
-
|
|
143
|
-
// VERTICAL
|
|
144
|
-
const {
|
|
145
|
-
deltaY
|
|
146
|
-
} = this.state;
|
|
147
|
-
return <Animated.View style={[style, {
|
|
148
|
-
transform: [{
|
|
149
|
-
translateY: deltaY
|
|
150
|
-
}]
|
|
151
|
-
}]} {...this.panResponder.panHandlers} onLayout={this.onLayout}>
|
|
152
|
-
{this.props.children}
|
|
153
|
-
</Animated.View>;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
export default asBaseComponent(PanGestureView);
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { PanningDirections, PanDirectionsProps, PanAmountsProps } from './panningProvider';
|
|
3
|
-
import { ViewProps } from '../view';
|
|
4
|
-
interface PanningProps {
|
|
5
|
-
/**
|
|
6
|
-
* This is were you will get notified when a drag occurs
|
|
7
|
-
* onDrag = ({directions, deltas}) => {...}
|
|
8
|
-
* directions - array of directions
|
|
9
|
-
* deltas - array of deltas (same length and order as directions)
|
|
10
|
-
* Both arrays will have {x, y} - if no x or y drag has occurred this value will be undefined
|
|
11
|
-
*/
|
|
12
|
-
onDrag?: ({ directions, deltas }: ({
|
|
13
|
-
directions: PanDirectionsProps;
|
|
14
|
-
deltas: PanAmountsProps;
|
|
15
|
-
})) => void;
|
|
16
|
-
/**
|
|
17
|
-
* This is were you will get notified when a swipe occurs
|
|
18
|
-
* onSwipe = ({directions, velocities}) => {...}
|
|
19
|
-
* directions - array of directions
|
|
20
|
-
* velocities - array of velocities (same length and order as directions)
|
|
21
|
-
* Both arrays will have {x, y} - if no x or y swipe has occurred this value will be undefined
|
|
22
|
-
*/
|
|
23
|
-
onSwipe?: ({ directions, velocities }: ({
|
|
24
|
-
directions: PanDirectionsProps;
|
|
25
|
-
velocities: PanAmountsProps;
|
|
26
|
-
})) => void;
|
|
27
|
-
/**
|
|
28
|
-
* This is were you will get notified when the pan starts
|
|
29
|
-
*/
|
|
30
|
-
onPanStart?: () => void;
|
|
31
|
-
/**
|
|
32
|
-
* This is were you will get notified when the pan ends
|
|
33
|
-
* The user has released all touches while this view is the responder.
|
|
34
|
-
* This typically means a gesture has succeeded
|
|
35
|
-
*/
|
|
36
|
-
onPanRelease?: () => void;
|
|
37
|
-
/**
|
|
38
|
-
* This is were you will get notified when the pan ends
|
|
39
|
-
* Another component has become the responder,
|
|
40
|
-
* so this gesture should be cancelled
|
|
41
|
-
*/
|
|
42
|
-
onPanTerminated?: () => void;
|
|
43
|
-
}
|
|
44
|
-
export interface PanListenerViewProps extends PanningProps, ViewProps {
|
|
45
|
-
/**
|
|
46
|
-
* The directions of the allowed pan (default allows all directions)
|
|
47
|
-
* Types: UP, DOWN, LEFT and RIGHT (using PanningProvider.Directions.###)
|
|
48
|
-
*/
|
|
49
|
-
directions?: PanningDirections[];
|
|
50
|
-
/**
|
|
51
|
-
* The sensitivity beyond which a pan is no longer considered a single click (default is 5)
|
|
52
|
-
*/
|
|
53
|
-
panSensitivity?: number;
|
|
54
|
-
/**
|
|
55
|
-
* The sensitivity beyond which a pan is no longer considered a drag, but a swipe (default is 1.8)
|
|
56
|
-
* Note: a pan would have to occur (i.e. the panSensitivity has already been surpassed)
|
|
57
|
-
*/
|
|
58
|
-
swipeVelocitySensitivity?: number;
|
|
59
|
-
/**
|
|
60
|
-
* Is there a view that is clickable (has onPress etc.) in the PanListenerView.
|
|
61
|
-
* This can affect the panability of this component.
|
|
62
|
-
*/
|
|
63
|
-
isClickable?: boolean;
|
|
64
|
-
}
|
|
65
|
-
declare const _default: React.ComponentClass<PanListenerViewProps, any>;
|
|
66
|
-
export default _default;
|