react-native-ui-lib 7.46.3-snapshot.7341 → 7.46.3-snapshot.7342
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 +0 -12
- package/index.js +0 -1
- package/lib/android/build.gradle +5 -5
- package/lib/android/src/main/java/com/wix/reactnativeuilib/UiLibPackageList.java +2 -0
- package/lib/android/src/main/java/com/wix/reactnativeuilib/highlighterview/HighlighterViewManager.java +23 -31
- package/lib/android/src/main/java/com/wix/reactnativeuilib/highlighterview/ReactHacks.java +30 -0
- package/lib/android/src/main/java/com/wix/reactnativeuilib/highlighterview/ReflectionUtils.java +34 -0
- package/lib/android/src/main/java/com/wix/reactnativeuilib/keyboardinput/utils/RuntimeUtils.java +1 -1
- package/lib/android/src/main/java/com/wix/reactnativeuilib/textinput/DefaultKeyListener.java +33 -0
- package/lib/android/src/main/java/com/wix/reactnativeuilib/textinput/KeyListenerProxy.java +53 -0
- package/lib/android/src/main/java/com/wix/reactnativeuilib/textinput/TextInputDelKeyHandlerModule.java +54 -0
- package/lib/android/src/main/java/com/wix/reactnativeuilib/textinput/TextInputDelKeyHandlerPackage.java +28 -0
- package/lib/android/src/main/java/com/wix/reactnativeuilib/textinput/ViewUtils.java +36 -0
- package/lib/components/{HighlighterOverlayView/index.d.ts → HighlighterOverlayView.d.ts} +1 -1
- package/lib/components/HighlighterOverlayView.js +40 -0
- package/lib/components/{HighlighterOverlayView/index.web.d.ts → HighlighterOverlayView.web.d.ts} +1 -1
- package/lib/components/Keyboard/{KeyboardAccessoryView → KeyboardInput}/CustomKeyboardView/CustomKeyboardView.android.d.ts +2 -5
- package/lib/components/Keyboard/KeyboardInput/CustomKeyboardView/CustomKeyboardView.android.js +28 -0
- package/lib/components/Keyboard/{KeyboardAccessoryView → KeyboardInput}/CustomKeyboardView/CustomKeyboardView.ios.d.ts +1 -1
- package/lib/components/Keyboard/{KeyboardAccessoryView → KeyboardInput}/CustomKeyboardView/CustomKeyboardView.ios.js +3 -3
- package/lib/components/Keyboard/{KeyboardAccessoryView/CustomKeyboardView → KeyboardInput}/CustomKeyboardViewBase.d.ts +0 -3
- package/lib/components/Keyboard/{KeyboardAccessoryView/CustomKeyboardView → KeyboardInput}/CustomKeyboardViewBase.js +1 -1
- package/lib/components/Keyboard/{KeyboardAccessoryView/index.d.ts → KeyboardInput/KeyboardAccessoryView.d.ts} +1 -11
- package/lib/components/Keyboard/{KeyboardAccessoryView/index.js → KeyboardInput/KeyboardAccessoryView.js} +5 -31
- package/lib/components/Keyboard/{KeyboardAccessoryView/KeyboardRegistry/index.d.ts → KeyboardInput/KeyboardRegistry.d.ts} +1 -1
- package/lib/components/Keyboard/{KeyboardAccessoryView/KeyboardRegistry/index.js → KeyboardInput/KeyboardRegistry.js} +1 -1
- package/lib/components/Keyboard/{KeyboardAccessoryView/KeyboardRegistry → KeyboardInput}/__tests__/KeyboardRegistry.spec.js +1 -1
- package/lib/components/Keyboard/{KeyboardAccessoryView → KeyboardInput}/keyboardAccessoryView.api.json +5 -5
- package/lib/components/Keyboard/{KeyboardAccessoryView/KeyboardRegistry → KeyboardInput}/keyboardRegistry.api.json +9 -9
- package/lib/components/Keyboard/KeyboardInput/utils/KeyboardUtils.d.ts +11 -0
- package/lib/components/Keyboard/KeyboardInput/utils/KeyboardUtils.js +17 -0
- package/lib/components/Keyboard/{KeyboardAccessoryView/KeyboardRegistry/EventEmitterManager → KeyboardInput/utils}/__tests__/EventEmitterManager.spec.js +1 -1
- package/lib/components/Keyboard/{KeyboardAwareInsetsView/index.d.ts → KeyboardTracking/KeyboardAwareInsetsView.d.ts} +1 -1
- package/lib/components/Keyboard/{KeyboardAwareInsetsView/index.js → KeyboardTracking/KeyboardAwareInsetsView.js} +1 -1
- package/lib/components/Keyboard/{KeyboardTrackingView → KeyboardTracking/KeyboardTrackingView}/KeyboardTrackingView.ios.d.ts +4 -1
- package/lib/components/Keyboard/{KeyboardTrackingView → KeyboardTracking/KeyboardTrackingView}/KeyboardTrackingView.ios.js +8 -5
- package/lib/components/Keyboard/{KeyboardTrackingView → KeyboardTracking/KeyboardTrackingView}/index.d.ts +2 -2
- package/lib/components/Keyboard/{KeyboardTrackingView → KeyboardTracking/KeyboardTrackingView}/keyboardTrackingView.api.json +20 -11
- package/lib/components/Keyboard/index.d.ts +6 -6
- package/lib/components/Keyboard/index.js +6 -6
- package/lib/components/SafeArea/SafeAreaInsetsManager.d.ts +7 -21
- package/lib/components/SafeArea/SafeAreaInsetsManager.js +31 -95
- package/lib/components/SafeArea/SafeAreaSpacerView.d.ts +2 -2
- package/lib/components/SafeArea/SafeAreaSpacerView.js +9 -63
- package/lib/components/index.d.ts +1 -1
- package/lib/components/index.js +1 -1
- package/lib/ios/reactnativeuilib/keyboardinput/rctcustomInputcontroller/RCTCustomInputControllerTemp.m +8 -52
- package/lib/ios/reactnativeuilib/keyboardinput/rctcustomInputcontroller/RCTCustomKeyboardViewControllerTemp.h +7 -1
- package/lib/ios/reactnativeuilib/keyboardinput/rctcustomInputcontroller/RCTCustomKeyboardViewControllerTemp.m +1 -1
- package/lib/ios/reactnativeuilib/keyboardtrackingview/KeyboardTrackingViewTempManager.m +41 -109
- package/lib/package.json +1 -1
- package/lib/react-native.config.js +3 -1
- package/metro.config.js +2 -2
- package/package.json +25 -25
- package/panningViews.d.ts +2 -0
- package/panningViews.js +1 -0
- package/react-native.config.js +3 -1
- package/scripts/release/prReleaseNotesCommon.js +15 -4
- package/sharedTransition.d.ts +2 -0
- package/sharedTransition.js +1 -0
- package/src/commons/Constants.js +5 -2
- package/src/components/KeyboardAwareScrollView/KeyboardAwareBase.js +1 -5
- package/src/components/actionSheet/index.d.ts +12 -2
- package/src/components/actionSheet/index.js +42 -3
- package/src/components/badge/index.d.ts +47 -107
- package/src/components/button/button.api.json +1 -1
- package/src/components/button/index.d.ts +23 -53
- package/src/components/button/types.d.ts +1 -0
- package/src/components/colorPicker/ColorPickerDialog.d.ts +1 -1
- package/src/components/colorPicker/ColorPickerDialog.js +1 -1
- package/src/components/dateTimePicker/index.d.ts +5 -186
- package/src/components/dateTimePicker/index.js +4 -3
- package/src/components/dialog/DialogDismissibleView.d.ts +34 -0
- package/src/components/dialog/DialogDismissibleView.js +184 -0
- package/src/components/dialog/OverlayFadingBackground.d.ts +14 -0
- package/src/components/dialog/OverlayFadingBackground.js +45 -0
- package/src/components/dialog/dialog.api.json +37 -31
- package/src/components/dialog/index.d.ts +105 -13
- package/src/components/dialog/index.js +212 -204
- package/src/components/drawer/Swipeable.js +2 -1
- package/src/components/drawer/index.js +25 -31
- package/src/components/fadedScrollView/index.js +2 -7
- package/src/components/featureHighlight/index.d.ts +1 -1
- package/src/components/index.js +19 -0
- package/src/components/marquee/types.js +1 -4
- package/src/components/modal/index.d.ts +0 -5
- package/src/components/modal/index.js +10 -14
- package/src/components/modal/modal.api.json +0 -5
- package/src/components/panningViews/asPanViewConsumer.d.ts +3 -0
- package/src/components/panningViews/asPanViewConsumer.js +16 -0
- package/src/components/panningViews/panDismissibleView.d.ts +51 -0
- package/src/components/panningViews/panDismissibleView.js +350 -0
- package/src/components/panningViews/panGestureView.d.ts +23 -0
- package/src/components/panningViews/panGestureView.js +156 -0
- package/src/components/panningViews/panListenerView.d.ts +66 -0
- package/src/components/panningViews/panListenerView.js +155 -0
- package/src/components/panningViews/panResponderView.d.ts +19 -0
- package/src/components/panningViews/panResponderView.js +79 -0
- package/src/components/panningViews/panningContext.d.ts +3 -0
- package/src/components/panningViews/panningContext.js +4 -0
- package/src/components/panningViews/panningProvider.d.ts +73 -0
- package/src/components/panningViews/panningProvider.js +101 -0
- 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 +20 -6
- package/src/components/picker/PickerPresenter.d.ts +1 -0
- package/src/components/picker/PickerPresenter.js +23 -1
- package/src/components/picker/api/picker.api.json +1 -0
- package/src/components/picker/api/pickerItem.api.json +5 -0
- package/src/components/picker/helpers/useFieldType.d.ts +23 -53
- package/src/components/picker/helpers/usePickerLabel.d.ts +1 -1
- package/src/components/picker/helpers/usePickerLabel.js +3 -2
- package/src/components/picker/helpers/usePickerMigrationWarnings.d.ts +1 -1
- package/src/components/picker/helpers/usePickerMigrationWarnings.js +12 -0
- package/src/components/picker/helpers/usePickerSearch.d.ts +1 -1
- package/src/components/picker/helpers/usePickerSearch.js +8 -4
- package/src/components/picker/helpers/usePickerSelection.d.ts +1 -1
- package/src/components/picker/helpers/usePickerSelection.js +10 -2
- package/src/components/picker/index.js +22 -4
- package/src/components/picker/types.d.ts +24 -1
- package/src/components/segmentedControl/index.js +3 -3
- package/src/components/sharedTransition/ShareTransitionContext.js +3 -0
- package/src/components/sharedTransition/SharedArea.js +153 -0
- package/src/components/sharedTransition/SourceElement.js +44 -0
- package/src/components/sharedTransition/TargetElement.js +38 -0
- package/src/components/sharedTransition/index.js +9 -0
- package/src/components/slider/GradientSlider.d.ts +1 -1
- package/src/components/sortableGridList/SortableItem.js +4 -13
- package/src/components/sortableList/SortableListItem.js +4 -13
- package/src/components/stackAggregator/index.js +11 -16
- package/src/components/text/Text.driver.new.d.ts +2 -2
- package/src/components/text/Text.driver.new.js +2 -2
- package/src/components/textField/Input.js +1 -0
- 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 +46 -106
- package/src/components/textField/presets/underline.d.ts +46 -106
- package/src/components/textField/types.js +0 -1
- package/src/components/textField/usePreset.d.ts +44 -72
- package/src/components/timeline/types.js +0 -3
- package/src/incubator/dialog/dialog.api.json +54 -0
- package/src/{components → incubator}/dialog/dialogHeader.api.json +2 -2
- package/src/incubator/dialog/index.d.ts +15 -0
- package/src/incubator/dialog/index.js +218 -0
- package/src/{components → incubator}/dialog/types.d.ts +19 -0
- package/src/{components → incubator}/dialog/types.js +3 -1
- package/src/{components → incubator}/dialog/useDialogContent.d.ts +1 -1
- package/src/incubator/expandableOverlay/ExpandableOverlay.driver.js +1 -1
- package/src/incubator/expandableOverlay/index.d.ts +3 -42
- package/src/incubator/expandableOverlay/index.js +4 -1
- package/src/{hooks/useHiddenLocation/index.d.ts → incubator/hooks/useHiddenLocation.d.ts} +1 -1
- package/src/{hooks/useHiddenLocation/index.web.d.ts → incubator/hooks/useHiddenLocation.web.d.ts} +1 -1
- package/src/incubator/index.d.ts +2 -0
- package/src/incubator/index.js +2 -0
- package/src/{components → incubator}/panView/index.d.ts +3 -3
- package/src/{components → incubator}/panView/index.js +4 -4
- package/src/{components → incubator}/panView/usePanGesture.d.ts +1 -1
- package/src/incubator/toast/index.js +1 -1
- package/src/index.d.ts +10 -3
- package/src/index.js +162 -42
- package/src/testkit/index.d.ts +1 -1
- package/src/testkit/index.js +1 -1
- package/src/testkit/new/Component.driver.d.ts +1 -4
- package/src/testkit/new/Component.driver.js +3 -3
- package/lib/components/HighlighterOverlayView/index.js +0 -49
- package/lib/components/Keyboard/KeyboardAccessoryView/CustomKeyboardView/CustomKeyboardView.android.js +0 -51
- package/lib/components/Keyboard/KeyboardAccessoryView/KeyboardUtils/index.d.ts +0 -26
- package/lib/components/Keyboard/KeyboardAccessoryView/KeyboardUtils/index.js +0 -91
- package/lib/components/SafeArea/__tests__/SafeAreaInsetsManager.spec.js +0 -274
- package/lib/components/SafeArea/index.d.ts +0 -10
- package/lib/components/SafeArea/index.js +0 -11
- package/panView.d.ts +0 -2
- package/panView.js +0 -1
- /package/lib/components/{HighlighterOverlayView/index.web.js → HighlighterOverlayView.web.js} +0 -0
- /package/lib/components/Keyboard/{KeyboardAccessoryView → KeyboardInput}/CustomKeyboardView/index.d.ts +0 -0
- /package/lib/components/Keyboard/{KeyboardAccessoryView → KeyboardInput}/CustomKeyboardView/index.js +0 -0
- /package/lib/components/Keyboard/{KeyboardAccessoryView → KeyboardInput}/CustomKeyboardView/index.web.d.ts +0 -0
- /package/lib/components/Keyboard/{KeyboardAccessoryView → KeyboardInput}/CustomKeyboardView/index.web.js +0 -0
- /package/lib/components/Keyboard/{KeyboardAccessoryView → KeyboardInput}/TextInputKeyboardManager/TextInputKeyboardManager.android.d.ts +0 -0
- /package/lib/components/Keyboard/{KeyboardAccessoryView → KeyboardInput}/TextInputKeyboardManager/TextInputKeyboardManager.android.js +0 -0
- /package/lib/components/Keyboard/{KeyboardAccessoryView → KeyboardInput}/TextInputKeyboardManager/TextInputKeyboardManager.ios.d.ts +0 -0
- /package/lib/components/Keyboard/{KeyboardAccessoryView → KeyboardInput}/TextInputKeyboardManager/TextInputKeyboardManager.ios.js +0 -0
- /package/lib/components/Keyboard/{KeyboardAccessoryView → KeyboardInput}/TextInputKeyboardManager/index.d.ts +0 -0
- /package/lib/components/Keyboard/{KeyboardAccessoryView → KeyboardInput}/TextInputKeyboardManager/index.js +0 -0
- /package/lib/components/Keyboard/{KeyboardAccessoryView/KeyboardRegistry/EventEmitterManager/index.d.ts → KeyboardInput/utils/EventEmitterManager.d.ts} +0 -0
- /package/lib/components/Keyboard/{KeyboardAccessoryView/KeyboardRegistry/EventEmitterManager/index.js → KeyboardInput/utils/EventEmitterManager.js} +0 -0
- /package/lib/components/Keyboard/{KeyboardTrackingView → KeyboardTracking/KeyboardTrackingView}/KeyboardTrackingView.android.d.ts +0 -0
- /package/lib/components/Keyboard/{KeyboardTrackingView → KeyboardTracking/KeyboardTrackingView}/KeyboardTrackingView.android.js +0 -0
- /package/lib/components/Keyboard/{KeyboardTrackingView → KeyboardTracking/KeyboardTrackingView}/index.js +0 -0
- /package/lib/components/Keyboard/{KeyboardTrackingView → KeyboardTracking/KeyboardTrackingView}/index.web.d.ts +0 -0
- /package/lib/components/Keyboard/{KeyboardTrackingView → KeyboardTracking/KeyboardTrackingView}/index.web.js +0 -0
- /package/lib/components/Keyboard/{KeyboardAwareInsetsView → KeyboardTracking}/keyboardAwareInsetsView.api.json +0 -0
- /package/src/{components → incubator}/dialog/Dialog.driver.new.d.ts +0 -0
- /package/src/{components → incubator}/dialog/Dialog.driver.new.js +0 -0
- /package/src/{components → incubator}/dialog/DialogHeader.d.ts +0 -0
- /package/src/{components → incubator}/dialog/DialogHeader.js +0 -0
- /package/src/{components → incubator}/dialog/useDialogContent.js +0 -0
- /package/src/{hooks/useHiddenLocation/index.js → incubator/hooks/useHiddenLocation.js} +0 -0
- /package/src/{hooks/useHiddenLocation/index.web.js → incubator/hooks/useHiddenLocation.web.js} +0 -0
- /package/src/{components → incubator}/panView/panningUtil.d.ts +0 -0
- /package/src/{components → incubator}/panView/panningUtil.js +0 -0
- /package/src/{components → incubator}/panView/usePanGesture.js +0 -0
|
@@ -0,0 +1,156 @@
|
|
|
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);
|
|
@@ -0,0 +1,66 @@
|
|
|
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;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import _isUndefined from "lodash/isUndefined";
|
|
2
|
+
import React, { PureComponent } from 'react';
|
|
3
|
+
import { PanResponder } from 'react-native';
|
|
4
|
+
import asPanViewConsumer from "./asPanViewConsumer";
|
|
5
|
+
import PanningProvider from "./panningProvider";
|
|
6
|
+
import View from "../view";
|
|
7
|
+
const DEFAULT_DIRECTIONS = [PanningProvider.Directions.UP, PanningProvider.Directions.DOWN, PanningProvider.Directions.LEFT, PanningProvider.Directions.RIGHT];
|
|
8
|
+
const DEFAULT_PAN_SENSITIVITY = 5;
|
|
9
|
+
const DEFAULT_SWIPE_VELOCITY = 1.8;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @description: PanListenerView component created to making listening to swipe and drag events easier
|
|
13
|
+
* @example: https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/componentScreens/PanListenerScreen.tsx
|
|
14
|
+
* @gif: https://github.com/wix/react-native-ui-lib/blob/master/demo/showcase/PanListenerView/PanListenerView.gif?raw=true
|
|
15
|
+
*/
|
|
16
|
+
class PanListenerView extends PureComponent {
|
|
17
|
+
static displayName = 'IGNORE';
|
|
18
|
+
static defaultProps = {
|
|
19
|
+
directions: DEFAULT_DIRECTIONS,
|
|
20
|
+
panSensitivity: DEFAULT_PAN_SENSITIVITY,
|
|
21
|
+
swipeVelocitySensitivity: DEFAULT_SWIPE_VELOCITY
|
|
22
|
+
};
|
|
23
|
+
constructor(props) {
|
|
24
|
+
super(props);
|
|
25
|
+
const {
|
|
26
|
+
isClickable
|
|
27
|
+
} = props;
|
|
28
|
+
this.panResponder = PanResponder.create({
|
|
29
|
+
onStartShouldSetPanResponder: isClickable ? this.shouldPan : this.yes,
|
|
30
|
+
onMoveShouldSetPanResponder: this.shouldPan,
|
|
31
|
+
onStartShouldSetPanResponderCapture: this.no,
|
|
32
|
+
onMoveShouldSetPanResponderCapture: this.no,
|
|
33
|
+
onPanResponderGrant: this.handlePanStart,
|
|
34
|
+
onPanResponderMove: this.handlePanMove,
|
|
35
|
+
onPanResponderRelease: this.handlePanRelease,
|
|
36
|
+
onPanResponderTerminate: this.handlePanTerminate
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
yes = () => {
|
|
40
|
+
return true;
|
|
41
|
+
};
|
|
42
|
+
no = () => {
|
|
43
|
+
return false;
|
|
44
|
+
};
|
|
45
|
+
shouldPan = (_e, gestureState) => {
|
|
46
|
+
// return true if user is swiping, return false if it's a single click
|
|
47
|
+
const {
|
|
48
|
+
dy,
|
|
49
|
+
dx
|
|
50
|
+
} = gestureState;
|
|
51
|
+
const {
|
|
52
|
+
directions,
|
|
53
|
+
panSensitivity = DEFAULT_PAN_SENSITIVITY
|
|
54
|
+
} = this.props;
|
|
55
|
+
return Boolean(directions && (directions.includes(PanningProvider.Directions.UP) && dy < -panSensitivity || directions.includes(PanningProvider.Directions.DOWN) && dy > panSensitivity || directions.includes(PanningProvider.Directions.LEFT) && dx < -panSensitivity || directions.includes(PanningProvider.Directions.RIGHT) && dx > panSensitivity));
|
|
56
|
+
};
|
|
57
|
+
handlePanStart = () => {
|
|
58
|
+
this.props.onPanStart?.();
|
|
59
|
+
this.props.context?.onPanStart?.();
|
|
60
|
+
};
|
|
61
|
+
getSwipeDirection = ({
|
|
62
|
+
vx,
|
|
63
|
+
vy
|
|
64
|
+
}) => {
|
|
65
|
+
const {
|
|
66
|
+
swipeVelocitySensitivity = DEFAULT_SWIPE_VELOCITY
|
|
67
|
+
} = this.props;
|
|
68
|
+
return this.getDirectionsOverSensitivity(vx, vy, swipeVelocitySensitivity);
|
|
69
|
+
};
|
|
70
|
+
getDragDirection = ({
|
|
71
|
+
dx,
|
|
72
|
+
dy
|
|
73
|
+
}) => {
|
|
74
|
+
return this.getDirectionsOverSensitivity(dx, dy, 0);
|
|
75
|
+
};
|
|
76
|
+
getDirectionsOverSensitivity = (x, y, sensitivity) => {
|
|
77
|
+
const {
|
|
78
|
+
directions = DEFAULT_DIRECTIONS
|
|
79
|
+
} = this.props;
|
|
80
|
+
const selectedDirections = {};
|
|
81
|
+
const selectedAmounts = {};
|
|
82
|
+
if (directions.includes(PanningProvider.Directions.LEFT) && x < -sensitivity) {
|
|
83
|
+
selectedDirections.x = PanningProvider.Directions.LEFT;
|
|
84
|
+
selectedAmounts.x = x;
|
|
85
|
+
} else if (directions.includes(PanningProvider.Directions.RIGHT) && x > sensitivity) {
|
|
86
|
+
selectedDirections.x = PanningProvider.Directions.RIGHT;
|
|
87
|
+
selectedAmounts.x = x;
|
|
88
|
+
}
|
|
89
|
+
if (directions.includes(PanningProvider.Directions.UP) && y < -sensitivity) {
|
|
90
|
+
selectedDirections.y = PanningProvider.Directions.UP;
|
|
91
|
+
selectedAmounts.y = y;
|
|
92
|
+
} else if (directions.includes(PanningProvider.Directions.DOWN) && y > sensitivity) {
|
|
93
|
+
selectedDirections.y = PanningProvider.Directions.DOWN;
|
|
94
|
+
selectedAmounts.y = y;
|
|
95
|
+
}
|
|
96
|
+
return {
|
|
97
|
+
selectedDirections,
|
|
98
|
+
selectedAmounts
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
panResultHasValue = panResult => {
|
|
102
|
+
return Boolean(panResult && (panResult.selectedDirections.x || panResult.selectedDirections.y));
|
|
103
|
+
};
|
|
104
|
+
handlePanMove = (_e, gestureState) => {
|
|
105
|
+
const {
|
|
106
|
+
onSwipe,
|
|
107
|
+
onDrag,
|
|
108
|
+
context
|
|
109
|
+
} = this.props;
|
|
110
|
+
const hasSwipe = !_isUndefined(onSwipe);
|
|
111
|
+
const hasDrag = !_isUndefined(onDrag);
|
|
112
|
+
const hasContext = !_isUndefined(context);
|
|
113
|
+
let panResult;
|
|
114
|
+
if (hasSwipe || hasContext) {
|
|
115
|
+
panResult = this.getSwipeDirection(gestureState);
|
|
116
|
+
}
|
|
117
|
+
if (this.panResultHasValue(panResult)) {
|
|
118
|
+
// @ts-ignore
|
|
119
|
+
const data = {
|
|
120
|
+
directions: panResult.selectedDirections,
|
|
121
|
+
velocities: panResult.selectedAmounts
|
|
122
|
+
};
|
|
123
|
+
this.props.onSwipe?.(data);
|
|
124
|
+
context?.onSwipe?.(data);
|
|
125
|
+
} else if (hasDrag || hasContext) {
|
|
126
|
+
panResult = this.getDragDirection(gestureState);
|
|
127
|
+
if (this.panResultHasValue(panResult)) {
|
|
128
|
+
const data = {
|
|
129
|
+
directions: panResult.selectedDirections,
|
|
130
|
+
deltas: panResult.selectedAmounts
|
|
131
|
+
};
|
|
132
|
+
this.props.onDrag?.(data);
|
|
133
|
+
context?.onDrag?.(data);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
handlePanRelease = () => {
|
|
138
|
+
this.props.onPanRelease?.();
|
|
139
|
+
this.props.context?.onPanRelease?.();
|
|
140
|
+
};
|
|
141
|
+
handlePanTerminate = () => {
|
|
142
|
+
this.props.onPanTerminated?.();
|
|
143
|
+
this.props.context?.onPanTerminated?.();
|
|
144
|
+
};
|
|
145
|
+
render() {
|
|
146
|
+
const {
|
|
147
|
+
children,
|
|
148
|
+
...others
|
|
149
|
+
} = this.props;
|
|
150
|
+
return <View {...others} {...this.panResponder.panHandlers}>
|
|
151
|
+
{children}
|
|
152
|
+
</View>;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
export default asPanViewConsumer(PanListenerView);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ViewProps } from '../view';
|
|
3
|
+
import { PanLocationProps } from './panningProvider';
|
|
4
|
+
export interface PanResponderViewProps extends ViewProps {
|
|
5
|
+
/**
|
|
6
|
+
* Will be called with the current location ({left, top}) when the pan has ended
|
|
7
|
+
*/
|
|
8
|
+
onPanLocationChanged?: (location: PanLocationProps) => void;
|
|
9
|
+
/**
|
|
10
|
+
* Ignore panning events while this is true
|
|
11
|
+
*/
|
|
12
|
+
ignorePanning?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Allow the view to be animated (send animation via style; default is false)
|
|
15
|
+
*/
|
|
16
|
+
isAnimated?: boolean;
|
|
17
|
+
}
|
|
18
|
+
declare const _default: React.ComponentClass<PanResponderViewProps, any>;
|
|
19
|
+
export default _default;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import React, { PureComponent } from 'react';
|
|
2
|
+
import View from "../view";
|
|
3
|
+
import asPanViewConsumer from "./asPanViewConsumer";
|
|
4
|
+
/**
|
|
5
|
+
* @description: panResponderView component created to making listening to swipe and drag events easier.
|
|
6
|
+
* @notes: Has to be used as a child of a PanningProvider that also has a PanListenerView.
|
|
7
|
+
* The PanListenerView is the one that sends the drag\swipe events.
|
|
8
|
+
* @example: https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/componentScreens/PanResponderScreen.tsx
|
|
9
|
+
* @gif: https://github.com/wix/react-native-ui-lib/blob/master/demo/showcase/PanResponderView/PanResponderView.gif?raw=true
|
|
10
|
+
*/
|
|
11
|
+
class PanResponderView extends PureComponent {
|
|
12
|
+
static displayName = 'IGNORE';
|
|
13
|
+
static defaultProps = {
|
|
14
|
+
isAnimated: false
|
|
15
|
+
};
|
|
16
|
+
initialLeft = 0;
|
|
17
|
+
initialTop = 0;
|
|
18
|
+
ref = React.createRef();
|
|
19
|
+
componentDidMount() {
|
|
20
|
+
this.setNativeProps(this.initialLeft, this.initialTop);
|
|
21
|
+
}
|
|
22
|
+
componentDidUpdate(prevProps) {
|
|
23
|
+
const {
|
|
24
|
+
ignorePanning
|
|
25
|
+
} = this.props;
|
|
26
|
+
const {
|
|
27
|
+
isPanning,
|
|
28
|
+
dragDeltas
|
|
29
|
+
} = this.props.context;
|
|
30
|
+
const {
|
|
31
|
+
isPanning: prevIsPanning,
|
|
32
|
+
dragDeltas: prevDragDeltas
|
|
33
|
+
} = prevProps.context;
|
|
34
|
+
if (!ignorePanning && !isPanning && prevIsPanning) {
|
|
35
|
+
this.onPanEnd();
|
|
36
|
+
}
|
|
37
|
+
if (!ignorePanning && isPanning && (dragDeltas.x || dragDeltas.y) && (dragDeltas.x !== prevDragDeltas.x || dragDeltas.y !== prevDragDeltas.y)) {
|
|
38
|
+
this.onDrag(dragDeltas);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
onPanEnd() {
|
|
42
|
+
const location = {
|
|
43
|
+
left: this.left,
|
|
44
|
+
top: this.top
|
|
45
|
+
};
|
|
46
|
+
this.initialLeft = this.left || this.initialLeft;
|
|
47
|
+
this.initialTop = this.top || this.initialTop;
|
|
48
|
+
this.props.onPanLocationChanged?.(location);
|
|
49
|
+
//@ts-expect-error
|
|
50
|
+
this.props.context.onPanLocationChanged?.(location);
|
|
51
|
+
}
|
|
52
|
+
onDrag(deltas) {
|
|
53
|
+
const left = this.initialLeft + (deltas.x ? Math.round(deltas.x) : 0);
|
|
54
|
+
const top = this.initialTop + (deltas.y ? Math.round(deltas.y) : 0);
|
|
55
|
+
this.setNativeProps(left, top);
|
|
56
|
+
}
|
|
57
|
+
setNativeProps(left, top) {
|
|
58
|
+
if (this.ref.current) {
|
|
59
|
+
this.ref.current?.setNativeProps?.({
|
|
60
|
+
style: {
|
|
61
|
+
left,
|
|
62
|
+
top
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
this.left = left;
|
|
66
|
+
this.top = top;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
render() {
|
|
70
|
+
const {
|
|
71
|
+
isAnimated,
|
|
72
|
+
...others
|
|
73
|
+
} = this.props;
|
|
74
|
+
return <View animated={isAnimated} ref={this.ref} pointerEvents={'box-none'} {...others}>
|
|
75
|
+
{this.props.children}
|
|
76
|
+
</View>;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
export default asPanViewConsumer(PanResponderView);
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
export declare enum PanningDirectionsEnum {
|
|
3
|
+
UP = "up",
|
|
4
|
+
DOWN = "down",
|
|
5
|
+
LEFT = "left",
|
|
6
|
+
RIGHT = "right"
|
|
7
|
+
}
|
|
8
|
+
export type PanningDirectionsUnion = `${PanningDirectionsEnum}`;
|
|
9
|
+
export type PanningDirections = PanningDirectionsEnum | PanningDirectionsUnion;
|
|
10
|
+
export interface PanLocationProps {
|
|
11
|
+
left?: number;
|
|
12
|
+
top?: number;
|
|
13
|
+
}
|
|
14
|
+
export interface PanDirectionsProps {
|
|
15
|
+
x?: PanningDirections;
|
|
16
|
+
y?: PanningDirections;
|
|
17
|
+
}
|
|
18
|
+
export interface PanAmountsProps {
|
|
19
|
+
x?: number;
|
|
20
|
+
y?: number;
|
|
21
|
+
}
|
|
22
|
+
interface State {
|
|
23
|
+
isPanning: boolean;
|
|
24
|
+
wasTerminated: boolean;
|
|
25
|
+
dragDirections: PanDirectionsProps;
|
|
26
|
+
dragDeltas: PanAmountsProps;
|
|
27
|
+
swipeDirections: PanDirectionsProps;
|
|
28
|
+
swipeVelocities: PanAmountsProps;
|
|
29
|
+
panLocation: PanLocationProps;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* @description: Wraps the panResponderView and panListenerView to provide a shared context
|
|
33
|
+
*/
|
|
34
|
+
export default class PanningProvider extends Component<any, State> {
|
|
35
|
+
static displayName: string;
|
|
36
|
+
static Directions: typeof PanningDirectionsEnum;
|
|
37
|
+
constructor(props: any);
|
|
38
|
+
getProviderContextValue: () => {
|
|
39
|
+
onPanStart: () => void;
|
|
40
|
+
onPanRelease: () => void;
|
|
41
|
+
onPanTerminated: () => void;
|
|
42
|
+
isPanning: boolean;
|
|
43
|
+
wasTerminated: boolean;
|
|
44
|
+
onDrag: ({ directions, deltas }: {
|
|
45
|
+
directions: PanDirectionsProps;
|
|
46
|
+
deltas: PanAmountsProps;
|
|
47
|
+
}) => void;
|
|
48
|
+
dragDirections: PanDirectionsProps;
|
|
49
|
+
dragDeltas: PanAmountsProps;
|
|
50
|
+
onSwipe: ({ directions, velocities }: {
|
|
51
|
+
directions: PanDirectionsProps;
|
|
52
|
+
velocities: PanAmountsProps;
|
|
53
|
+
}) => void;
|
|
54
|
+
swipeDirections: PanDirectionsProps;
|
|
55
|
+
swipeVelocities: PanAmountsProps;
|
|
56
|
+
onPanLocationChanged: (location: PanLocationProps) => void;
|
|
57
|
+
panLocation: PanLocationProps;
|
|
58
|
+
};
|
|
59
|
+
onPanStart: () => void;
|
|
60
|
+
onPanRelease: () => void;
|
|
61
|
+
onPanTerminated: () => void;
|
|
62
|
+
onDrag: ({ directions, deltas }: {
|
|
63
|
+
directions: PanDirectionsProps;
|
|
64
|
+
deltas: PanAmountsProps;
|
|
65
|
+
}) => void;
|
|
66
|
+
onSwipe: ({ directions, velocities }: {
|
|
67
|
+
directions: PanDirectionsProps;
|
|
68
|
+
velocities: PanAmountsProps;
|
|
69
|
+
}) => void;
|
|
70
|
+
onPanLocationChanged: (location: PanLocationProps) => void;
|
|
71
|
+
render(): React.JSX.Element;
|
|
72
|
+
}
|
|
73
|
+
export {};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import PanningContext from "./panningContext";
|
|
3
|
+
export let PanningDirectionsEnum = /*#__PURE__*/function (PanningDirectionsEnum) {
|
|
4
|
+
PanningDirectionsEnum["UP"] = "up";
|
|
5
|
+
PanningDirectionsEnum["DOWN"] = "down";
|
|
6
|
+
PanningDirectionsEnum["LEFT"] = "left";
|
|
7
|
+
PanningDirectionsEnum["RIGHT"] = "right";
|
|
8
|
+
return PanningDirectionsEnum;
|
|
9
|
+
}({});
|
|
10
|
+
/**
|
|
11
|
+
* @description: Wraps the panResponderView and panListenerView to provide a shared context
|
|
12
|
+
*/
|
|
13
|
+
export default class PanningProvider extends Component {
|
|
14
|
+
static displayName = 'IGNORE';
|
|
15
|
+
static Directions = PanningDirectionsEnum;
|
|
16
|
+
constructor(props) {
|
|
17
|
+
super(props);
|
|
18
|
+
this.state = {
|
|
19
|
+
isPanning: false,
|
|
20
|
+
wasTerminated: false,
|
|
21
|
+
dragDirections: {},
|
|
22
|
+
dragDeltas: {},
|
|
23
|
+
swipeDirections: {},
|
|
24
|
+
swipeVelocities: {},
|
|
25
|
+
panLocation: {}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
getProviderContextValue = () => {
|
|
29
|
+
const {
|
|
30
|
+
isPanning,
|
|
31
|
+
wasTerminated,
|
|
32
|
+
dragDirections,
|
|
33
|
+
dragDeltas,
|
|
34
|
+
swipeDirections,
|
|
35
|
+
swipeVelocities,
|
|
36
|
+
panLocation
|
|
37
|
+
} = this.state;
|
|
38
|
+
return {
|
|
39
|
+
onPanStart: this.onPanStart,
|
|
40
|
+
onPanRelease: this.onPanRelease,
|
|
41
|
+
onPanTerminated: this.onPanTerminated,
|
|
42
|
+
isPanning,
|
|
43
|
+
wasTerminated,
|
|
44
|
+
onDrag: this.onDrag,
|
|
45
|
+
dragDirections,
|
|
46
|
+
dragDeltas,
|
|
47
|
+
onSwipe: this.onSwipe,
|
|
48
|
+
swipeDirections,
|
|
49
|
+
swipeVelocities,
|
|
50
|
+
onPanLocationChanged: this.onPanLocationChanged,
|
|
51
|
+
panLocation
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
onPanStart = () => {
|
|
55
|
+
this.setState({
|
|
56
|
+
isPanning: true,
|
|
57
|
+
wasTerminated: false
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
onPanRelease = () => {
|
|
61
|
+
this.setState({
|
|
62
|
+
isPanning: false
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
onPanTerminated = () => {
|
|
66
|
+
this.setState({
|
|
67
|
+
isPanning: false,
|
|
68
|
+
wasTerminated: true
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
onDrag = ({
|
|
72
|
+
directions,
|
|
73
|
+
deltas
|
|
74
|
+
}) => {
|
|
75
|
+
this.setState({
|
|
76
|
+
dragDirections: directions,
|
|
77
|
+
dragDeltas: deltas,
|
|
78
|
+
swipeDirections: {},
|
|
79
|
+
swipeVelocities: {}
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
onSwipe = ({
|
|
83
|
+
directions,
|
|
84
|
+
velocities
|
|
85
|
+
}) => {
|
|
86
|
+
this.setState({
|
|
87
|
+
swipeDirections: directions,
|
|
88
|
+
swipeVelocities: velocities,
|
|
89
|
+
dragDirections: {},
|
|
90
|
+
dragDeltas: {}
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
onPanLocationChanged = location => {
|
|
94
|
+
this.setState({
|
|
95
|
+
panLocation: location
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
render() {
|
|
99
|
+
return <PanningContext.Provider value={this.getProviderContextValue()}>{this.props.children}</PanningContext.Provider>;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const PickerDriver: (props: ComponentProps, useDialog: boolean
|
|
1
|
+
import { ComponentProps } from '../../testkit/new/Component.driver';
|
|
2
|
+
export declare const PickerDriver: (props: ComponentProps, useDialog: boolean) => {
|
|
3
3
|
exists: () => boolean;
|
|
4
4
|
getValue: () => string | undefined;
|
|
5
5
|
open: () => void;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { TextFieldDriver } from "../textField/TextField.driver.new";
|
|
2
2
|
import { ModalDriver } from "../modal/Modal.driver.new";
|
|
3
|
-
import { DialogDriver } from "
|
|
3
|
+
import { DialogDriver } from "../../incubator/dialog/Dialog.driver.new";
|
|
4
4
|
import { ButtonDriver } from "../button/Button.driver.new";
|
|
5
5
|
import { ExpandableOverlayDriver } from "../../incubator/expandableOverlay/ExpandableOverlay.driver";
|
|
6
|
-
export const PickerDriver = (props, useDialog
|
|
6
|
+
export const PickerDriver = (props, useDialog) => {
|
|
7
7
|
const expandableOverlayDriver = ExpandableOverlayDriver({
|
|
8
8
|
renderTree: props.renderTree,
|
|
9
9
|
testID: props.testID
|
|
@@ -11,7 +11,7 @@ export const PickerDriver = (props, useDialog, options) => {
|
|
|
11
11
|
const textFieldDriver = TextFieldDriver({
|
|
12
12
|
renderTree: props.renderTree,
|
|
13
13
|
testID: `${props.testID}.input`
|
|
14
|
-
}
|
|
14
|
+
});
|
|
15
15
|
const modalDriver = ModalDriver({
|
|
16
16
|
renderTree: props.renderTree,
|
|
17
17
|
testID: `${props.testID}.overlay`
|