@unikue/react-native-pull-refresh 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +96 -0
  3. package/dist/commonjs/DefaultLoading.js +89 -0
  4. package/dist/commonjs/DefaultLoading.js.map +1 -0
  5. package/dist/commonjs/LoadMore.js +31 -0
  6. package/dist/commonjs/LoadMore.js.map +1 -0
  7. package/dist/commonjs/LottieLoading.js +73 -0
  8. package/dist/commonjs/LottieLoading.js.map +1 -0
  9. package/dist/commonjs/PullRefresh.js +326 -0
  10. package/dist/commonjs/PullRefresh.js.map +1 -0
  11. package/dist/commonjs/assets/PinJump.json +1 -0
  12. package/dist/commonjs/assets/Watermelon.json +1 -0
  13. package/dist/commonjs/assets/hero.json +1 -0
  14. package/dist/commonjs/assets/hero.lottie +0 -0
  15. package/dist/commonjs/constants.js +33 -0
  16. package/dist/commonjs/constants.js.map +1 -0
  17. package/dist/commonjs/context.js +15 -0
  18. package/dist/commonjs/context.js.map +1 -0
  19. package/dist/commonjs/hooks.js +63 -0
  20. package/dist/commonjs/hooks.js.map +1 -0
  21. package/dist/commonjs/index.js +66 -0
  22. package/dist/commonjs/index.js.map +1 -0
  23. package/dist/commonjs/package.json +1 -0
  24. package/dist/commonjs/types/index.d.js +2 -0
  25. package/dist/commonjs/types/index.d.js.map +1 -0
  26. package/dist/commonjs/utils.js +53 -0
  27. package/dist/commonjs/utils.js.map +1 -0
  28. package/dist/commonjs/z.polyfily.js +4 -0
  29. package/dist/commonjs/z.polyfily.js.map +1 -0
  30. package/dist/module/DefaultLoading.js +80 -0
  31. package/dist/module/DefaultLoading.js.map +1 -0
  32. package/dist/module/LoadMore.js +25 -0
  33. package/dist/module/LoadMore.js.map +1 -0
  34. package/dist/module/LottieLoading.js +65 -0
  35. package/dist/module/LottieLoading.js.map +1 -0
  36. package/dist/module/PullRefresh.js +321 -0
  37. package/dist/module/PullRefresh.js.map +1 -0
  38. package/dist/module/assets/PinJump.json +1 -0
  39. package/dist/module/assets/Watermelon.json +1 -0
  40. package/dist/module/assets/hero.json +1 -0
  41. package/dist/module/assets/hero.lottie +0 -0
  42. package/dist/module/constants.js +28 -0
  43. package/dist/module/constants.js.map +1 -0
  44. package/dist/module/context.js +12 -0
  45. package/dist/module/context.js.map +1 -0
  46. package/dist/module/hooks.js +54 -0
  47. package/dist/module/hooks.js.map +1 -0
  48. package/dist/module/index.js +9 -0
  49. package/dist/module/index.js.map +1 -0
  50. package/dist/module/types/index.d.js +2 -0
  51. package/dist/module/types/index.d.js.map +1 -0
  52. package/dist/module/utils.js +40 -0
  53. package/dist/module/utils.js.map +1 -0
  54. package/dist/module/z.polyfily.js +4 -0
  55. package/dist/module/z.polyfily.js.map +1 -0
  56. package/dist/typescript/DefaultLoading.d.ts +9 -0
  57. package/dist/typescript/DefaultLoading.d.ts.map +1 -0
  58. package/dist/typescript/LoadMore.d.ts +8 -0
  59. package/dist/typescript/LoadMore.d.ts.map +1 -0
  60. package/dist/typescript/LottieLoading.d.ts +3 -0
  61. package/dist/typescript/LottieLoading.d.ts.map +1 -0
  62. package/dist/typescript/PullRefresh.d.ts +17 -0
  63. package/dist/typescript/PullRefresh.d.ts.map +1 -0
  64. package/dist/typescript/constants.d.ts +19 -0
  65. package/dist/typescript/constants.d.ts.map +1 -0
  66. package/dist/typescript/context.d.ts +17 -0
  67. package/dist/typescript/context.d.ts.map +1 -0
  68. package/dist/typescript/hooks.d.ts +30 -0
  69. package/dist/typescript/hooks.d.ts.map +1 -0
  70. package/dist/typescript/index.d.ts +7 -0
  71. package/dist/typescript/index.d.ts.map +1 -0
  72. package/dist/typescript/utils.d.ts +8 -0
  73. package/dist/typescript/utils.d.ts.map +1 -0
  74. package/dist/typescript/z.polyfily.d.ts +5 -0
  75. package/dist/typescript/z.polyfily.d.ts.map +1 -0
  76. package/package.json +123 -0
package/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 buddy <litoubuddy@gmail.com>
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,96 @@
1
+ # @unikue/react-native-pull-refresh
2
+
3
+
4
+ react-native pull refresh on iOS, Android and Web
5
+
6
+ ## ⚡Milestones
7
+ - Bump package versions to latest
8
+ - Fix `PullRefresh` `onScroll` event
9
+
10
+ ## 💪🏻 Support
11
+ | Platform | | solved |
12
+ |----------|---|-----------------------------------------------|
13
+ | iOS | ✅ | 🔥 Perfect |
14
+ | Android | ✅ | 😂 Bottom response is bad |
15
+ | Web | ✅ | 😭 Pulling and scrolling cant switch smoothly |
16
+
17
+ | Library | |
18
+ |------------------------------|-----|
19
+ | react-native-gesture-handler | 2.x |
20
+ | react-native-reanimated | 4.x |
21
+
22
+ #### ⚠️ Warning
23
+ `react-native-pull-refresh` Only support wrapper `Animated.ScrollView` and `Animated.FlatList`
24
+
25
+ not support nested PullRefresh!
26
+
27
+ ## Installation
28
+
29
+ It relies on `react-native-gesture-handler` and `react-native-reanimated`
30
+
31
+ so please install them before you use this package
32
+
33
+ ```sh
34
+ yarn install react-native-gesture-hanlder react-native-reanimated
35
+ ```
36
+
37
+ ```sh
38
+ yarn install @unikue/react-native-pull-refresh
39
+ ```
40
+
41
+ ## Usage
42
+
43
+ ```js
44
+ import { PullRefresh } from '@unikue/react-native-pull-refresh';
45
+
46
+ // ...
47
+
48
+ <PullRefresh
49
+ onPulldownRefresh={downLoader}
50
+ onPullupRefresh={upLoader}
51
+ pulldownHeight={80}
52
+ pullupHeight={100}
53
+ pullupEnabled={true}
54
+ >
55
+
56
+ <Animated.FlatList
57
+ data={[]}
58
+ renderItem={() => null}
59
+ />
60
+
61
+ {/* or*/}
62
+
63
+ <Animated.ScrollView>
64
+ {/* children */}
65
+ </Animated.ScrollView>
66
+ </PullRefresh>
67
+ ```
68
+
69
+ ## Example
70
+ | <img src="./gifs/ios.gif" alt="ios-example" width="240"> | <img src="./gifs/android.gif" alt="ios-example" width="250"> |
71
+ | :--------: | :-----------: |
72
+ | iOS | Android |
73
+
74
+
75
+ ## Props
76
+ | props | type | description | Default |
77
+ | ----------------- | --------- | ------------------------------------------------------------ | -------- |
78
+ | pulldownHeight | Number | The height of the drop-down load component is defined, and the judgment of the drop-down state depends on this value | 140 |
79
+ | pullupHeight | Number | The height of the pull-up component is defined, and the pull-up state is determined by this value | 100 |
80
+ | containerFactor | Number | The container factor is used to adjust the height of the refresh judgment | 0.5 |
81
+ | pullingFactor | Number | Determine the coefficient of pulling state length | 2.2 |
82
+ | pullupEnabled | Boolean | whether show pullingupLoading | false |
83
+ | pulldownLoading | Component | You can custom the Component | |
84
+ | pullupLoading | Component | You can custom the Component | |
85
+ | | | | |
86
+ | onPulldownRefresh | Function | callback of pulling down refresh, load data with it | ()=>void |
87
+ | onPullupRefresh | Function | callback of pulling up refresh, load data with it | ()=>void |
88
+
89
+
90
+ ## Contributing
91
+
92
+ See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
93
+
94
+ ## License
95
+
96
+ MIT
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.PullupLoading = exports.PulldownLoading = exports.Loading = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _reactNative = require("react-native");
9
+ var _reactNativeReanimated = _interopRequireDefault(require("react-native-reanimated"));
10
+ var _constants = require("./constants");
11
+ var _hooks = require("./hooks");
12
+ var _jsxRuntime = require("react/jsx-runtime");
13
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
15
+ // note: react-native-reanimated only suppot style-animation
16
+
17
+ const Loading = ({
18
+ animating
19
+ }) => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
20
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ActivityIndicator, {
21
+ animating: animating,
22
+ color: "#782aeb"
23
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
24
+ style: styles.ml8,
25
+ children: "Loading"
26
+ })]
27
+ });
28
+ exports.Loading = Loading;
29
+ const PulldownLoading = () => {
30
+ // eslint-disable-next-line @typescript-eslint/naming-convention
31
+ const [animating, setAnimating] = (0, _react.useState)(false);
32
+ (0, _hooks.useOnPulldownState)(state => {
33
+ if ([_constants.PullingRefreshStatus.LOADING, _constants.PullingRefreshStatus.PULLINGGO, _constants.PullingRefreshStatus.PULLINGBACK].includes(state)) {
34
+ setAnimating(true);
35
+ } else {
36
+ setAnimating(false);
37
+ }
38
+ });
39
+ const animatedStyle = (0, _hooks.usePulldownLoadingAnimation)();
40
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeReanimated.default.View, {
41
+ style: [styles.loadingrDownContainer, animatedStyle],
42
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Loading, {
43
+ animating: animating
44
+ })
45
+ });
46
+ };
47
+ exports.PulldownLoading = PulldownLoading;
48
+ const PullupLoading = () => {
49
+ // eslint-disable-next-line @typescript-eslint/naming-convention
50
+ const [animating, setAnimating] = (0, _react.useState)(false);
51
+ (0, _hooks.useOnPullupState)(state => {
52
+ if ([_constants.PullingRefreshStatus.LOADING, _constants.PullingRefreshStatus.PULLINGGO, _constants.PullingRefreshStatus.PULLINGBACK].includes(state)) {
53
+ setAnimating(true);
54
+ } else {
55
+ setAnimating(false);
56
+ }
57
+ });
58
+ const animatedStyle = (0, _hooks.usePullupLoadingAnimation)();
59
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeReanimated.default.View, {
60
+ style: [styles.loadingrUpContainer, animatedStyle],
61
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Loading, {
62
+ animating: animating
63
+ })
64
+ });
65
+ };
66
+ exports.PullupLoading = PullupLoading;
67
+ const styles = _reactNative.StyleSheet.create({
68
+ loadingrDownContainer: {
69
+ position: 'absolute',
70
+ flexDirection: 'row',
71
+ justifyContent: 'center',
72
+ alignItems: 'center',
73
+ width: '100%',
74
+ top: 0
75
+ },
76
+ loadingrUpContainer: {
77
+ position: 'absolute',
78
+ flexDirection: 'row',
79
+ justifyContent: 'center',
80
+ alignItems: 'center',
81
+ width: '100%',
82
+ bottom: 0,
83
+ height: 100
84
+ },
85
+ ml8: {
86
+ marginLeft: 8
87
+ }
88
+ });
89
+ //# sourceMappingURL=DefaultLoading.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeReanimated","_interopRequireDefault","_constants","_hooks","_jsxRuntime","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","Loading","animating","jsxs","Fragment","children","jsx","ActivityIndicator","color","Text","style","styles","ml8","exports","PulldownLoading","setAnimating","useState","useOnPulldownState","state","PullingRefreshStatus","LOADING","PULLINGGO","PULLINGBACK","includes","animatedStyle","usePulldownLoadingAnimation","View","loadingrDownContainer","PullupLoading","useOnPullupState","usePullupLoadingAnimation","loadingrUpContainer","StyleSheet","create","position","flexDirection","justifyContent","alignItems","width","top","bottom","height","marginLeft"],"sourceRoot":"../../src","sources":["DefaultLoading.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,sBAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,UAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAKiB,IAAAM,WAAA,GAAAN,OAAA;AAAA,SAAAG,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAR,wBAAAQ,CAAA,EAAAG,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAZ,uBAAA,YAAAA,CAAAQ,CAAA,EAAAG,CAAA,SAAAA,CAAA,IAAAH,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,MAAAO,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAR,OAAA,EAAAF,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SA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AnB,QAAA,eAChE,IAAAxB,WAAA,CAAAyB,GAAA,EAACL,OAAO;MAACC,SAAS,EAAEA;IAAU,CAAE;EAAC,CACpB,CAAC;AAEpB,CAAC;AAACW,OAAA,CAAAe,aAAA,GAAAA,aAAA;AAEF,MAAMjB,MAAM,GAAGqB,uBAAU,CAACC,MAAM,CAAC;EAC/BN,qBAAqB,EAAE;IACrBO,QAAQ,EAAE,UAAU;IACpBC,aAAa,EAAE,KAAK;IACpBC,cAAc,EAAE,QAAQ;IACxBC,UAAU,EAAE,QAAQ;IACpBC,KAAK,EAAE,MAAM;IACbC,GAAG,EAAE;EACP,CAAC;EACDR,mBAAmB,EAAE;IACnBG,QAAQ,EAAE,UAAU;IACpBC,aAAa,EAAE,KAAK;IACpBC,cAAc,EAAE,QAAQ;IACxBC,UAAU,EAAE,QAAQ;IACpBC,KAAK,EAAE,MAAM;IACbE,MAAM,EAAE,CAAC;IACTC,MAAM,EAAE;EACV,CAAC;EACD7B,GAAG,EAAE;IACH8B,UAAU,EAAE;EACd;AACF,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.InlineLoadMore = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _reactNative = require("react-native");
9
+ var _reactNativeReanimated = require("react-native-reanimated");
10
+ var _constants = require("./constants");
11
+ var _hooks = require("./hooks");
12
+ var _jsxRuntime = require("react/jsx-runtime");
13
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
+ const InlineLoadMore = ({
15
+ onLoadMore = _constants.FnNull
16
+ }) => {
17
+ const ctx = (0, _hooks.useMrPullRefreshValue)();
18
+ (0, _reactNativeReanimated.useAnimatedReaction)(() => ctx.scrollerOffsetY.value, (current, prev) => {
19
+ if (current !== prev) {
20
+ // TODO: 防抖
21
+ onLoadMore();
22
+ }
23
+ });
24
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
25
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
26
+ children: "LoadMore"
27
+ })
28
+ });
29
+ };
30
+ exports.InlineLoadMore = InlineLoadMore;
31
+ //# sourceMappingURL=LoadMore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","_interopRequireDefault","require","_reactNative","_reactNativeReanimated","_constants","_hooks","_jsxRuntime","e","__esModule","default","InlineLoadMore","onLoadMore","FnNull","ctx","useMrPullRefreshValue","useAnimatedReaction","scrollerOffsetY","value","current","prev","jsx","View","children","Text","exports"],"sourceRoot":"../../src","sources":["LoadMore.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,sBAAA,GAAAF,OAAA;AAEA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAAgD,IAAAK,WAAA,GAAAL,OAAA;AAAA,SAAAD,uBAAAO,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAMzC,MAAMG,cAA6C,GAAGA,CAAC;EAC5DC,UAAU,GAAGC;AACf,CAAC,KAAK;EACJ,MAAMC,GAAG,GAAG,IAAAC,4BAAqB,EAAC,CAAC;EAEnC,IAAAC,0CAAmB,EACjB,MAAMF,GAAG,CAACG,eAAe,CAACC,KAAK,EAC/B,CAACC,OAAO,EAAEC,IAAI,KAAK;IACjB,IAAID,OAAO,KAAKC,IAAI,EAAE;MACpB;MACAR,UAAU,CAAC,CAAC;IACd;EACF,CACF,CAAC;EAED,oBACE,IAAAL,WAAA,CAAAc,GAAA,EAAClB,YAAA,CAAAmB,IAAI;IAAAC,QAAA,eACH,IAAAhB,WAAA,CAAAc,GAAA,EAAClB,YAAA,CAAAqB,IAAI;MAAAD,QAAA,EAAC;IAAQ,CAAM;EAAC,CACjB,CAAC;AAEX,CAAC;AAACE,OAAA,CAAAd,cAAA,GAAAA,cAAA","ignoreList":[]}
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.HeroLottie = void 0;
7
+ var _lottieReactNative = _interopRequireDefault(require("lottie-react-native"));
8
+ var _react = _interopRequireWildcard(require("react"));
9
+ var _reactNative = require("react-native");
10
+ var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
11
+ var _hero = _interopRequireDefault(require("./assets/hero.json"));
12
+ var _constants = require("./constants");
13
+ var _hooks = require("./hooks");
14
+ var _utils = require("./utils");
15
+ var _jsxRuntime = require("react/jsx-runtime");
16
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
17
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
18
+ // import heroLottie from './assets/hero.lottie';
19
+
20
+ const AnimatedLottieView = _reactNativeReanimated.default.createAnimatedComponent(_lottieReactNative.default);
21
+ const HeroLottie = () => {
22
+ const lottieRef = (0, _react.useRef)(null);
23
+ const ctx = (0, _hooks.useMrPullRefreshValue)();
24
+ const {
25
+ pulldownHeight,
26
+ panTranslateY,
27
+ pulldownState,
28
+ containerY,
29
+ pullingFactor
30
+ } = ctx;
31
+ const animatedStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => ({
32
+ height: Math.min(panTranslateY.value, pulldownHeight),
33
+ opacity: (0, _reactNativeReanimated.interpolate)(panTranslateY.value, [0, pulldownHeight], [0, 1])
34
+ }));
35
+ (0, _hooks.useOnPulldownState)(value => {
36
+ if (value === _constants.PullingRefreshStatus.PULLINGGO) {
37
+ lottieRef.current?.play();
38
+ }
39
+ if (value === _constants.PullingRefreshStatus.BACKUP) {
40
+ lottieRef.current?.reset();
41
+ }
42
+ });
43
+ const progress = (0, _reactNativeReanimated.useDerivedValue)(() => [_constants.PullingRefreshStatus.BACKUP, _constants.PullingRefreshStatus.PULLING].includes(pulldownState.value) ? (0, _reactNativeReanimated.interpolate)((0, _utils.actuallyMove)(panTranslateY.value, containerY.value), [0, pulldownHeight * pullingFactor], [0, 1], _reactNativeReanimated.Extrapolate.CLAMP) : undefined);
44
+
45
+ // TODO: Fixed Do it.
46
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeReanimated.default.View, {
47
+ style: [{
48
+ position: 'absolute',
49
+ top: 0,
50
+ width: '100%',
51
+ height: pulldownHeight
52
+ }],
53
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(AnimatedLottieView, {
54
+ progress: progress,
55
+ style: [styles.fullBox, animatedStyle],
56
+ ref: lottieRef,
57
+ source: _hero.default
58
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
59
+ // @ts-ignore
60
+ // sourceDotLottieURI={heroLottie}
61
+ ,
62
+ autoPlay: true
63
+ })
64
+ });
65
+ };
66
+ exports.HeroLottie = HeroLottie;
67
+ const styles = _reactNative.StyleSheet.create({
68
+ fullBox: {
69
+ width: '100%',
70
+ height: '100%'
71
+ }
72
+ });
73
+ //# sourceMappingURL=LottieLoading.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_lottieReactNative","_interopRequireDefault","require","_react","_interopRequireWildcard","_reactNative","_reactNativeReanimated","_hero","_constants","_hooks","_utils","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","AnimatedLottieView","Animated","createAnimatedComponent","LottieView","HeroLottie","lottieRef","useRef","ctx","useMrPullRefreshValue","pulldownHeight","panTranslateY","pulldownState","containerY","pullingFactor","animatedStyle","useAnimatedStyle","height","Math","min","value","opacity","interpolate","useOnPulldownState","PullingRefreshStatus","PULLINGGO","current","play","BACKUP","reset","progress","useDerivedValue","PULLING","includes","actuallyMove","Extrapolate","CLAMP","undefined","jsx","View","style","position","top","width","children","styles","fullBox","ref","source","heroJson","autoPlay","exports","StyleSheet","create"],"sourceRoot":"../../src","sources":["LottieLoading.tsx"],"mappings":";;;;;;AAAA,IAAAA,kBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,uBAAA,CAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,sBAAA,GAAAF,uBAAA,CAAAF,OAAA;AAOA,IAAAK,KAAA,GAAAN,sBAAA,CAAAC,OAAA;AAEA,IAAAM,UAAA,GAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AACA,IAAAQ,MAAA,GAAAR,OAAA;AAAuC,IAAAS,WAAA,GAAAT,OAAA;AAAA,SAAAE,wBAAAQ,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAV,uBAAA,YAAAA,CAAAQ,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CA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K,EAAE,MAAM;IACb1B,MAAM,EAAE;EACV;AACF,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,326 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.PullRefresh = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _reactNative = require("react-native");
9
+ var _reactNativeGestureHandler = require("react-native-gesture-handler");
10
+ var _reactNativeReanimated = require("react-native-reanimated");
11
+ var _constants = require("./constants");
12
+ var _context = require("./context");
13
+ var _DefaultLoading = require("./DefaultLoading");
14
+ var _utils = require("./utils");
15
+ var _jsxRuntime = require("react/jsx-runtime");
16
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
17
+ const RefreshWrapper = ({
18
+ onPulldownRefresh = _constants.FnNull,
19
+ onPullupRefresh = _constants.FnNull,
20
+ pulldownHeight = 80,
21
+ pullupHeight = 100,
22
+ pulldownLoading = /*#__PURE__*/(0, _jsxRuntime.jsx)(_DefaultLoading.PulldownLoading, {}),
23
+ pullupLoading = /*#__PURE__*/(0, _jsxRuntime.jsx)(_DefaultLoading.PullupLoading, {}),
24
+ containerFactor = 0.5,
25
+ pullingFactor = 2.2,
26
+ pullupEnabled = false /* TODO: will re-render */,
27
+ style,
28
+ children
29
+ }) => {
30
+ // custom
31
+ const pulldownState = (0, _reactNativeReanimated.useSharedValue)(_constants.PullingRefreshStatus.IDLE);
32
+ const pullupState = (0, _reactNativeReanimated.useSharedValue)(_constants.PullingRefreshStatus.IDLE);
33
+ const containerY = (0, _reactNativeReanimated.useSharedValue)(0);
34
+ const contentY = (0, _reactNativeReanimated.useSharedValue)(0);
35
+ const scrollerOffsetY = (0, _reactNativeReanimated.useSharedValue)(0);
36
+ const panTranslateY = (0, _reactNativeReanimated.useSharedValue)(0);
37
+ const recordValue = (0, _reactNativeReanimated.useSharedValue)(0);
38
+ const lockIDLE = (0, _reactNativeReanimated.useSharedValue)(0);
39
+
40
+ // TODO: By ClassComponent ?
41
+ const onPulldownLoading = async () => {
42
+ const res = onPulldownRefresh();
43
+ if ((0, _utils.isPromise)(res)) {
44
+ await res;
45
+ }
46
+ (0, _reactNativeReanimated.runOnUI)(() => {
47
+ 'worklet';
48
+
49
+ pulldownState.value = _constants.PullingRefreshStatus.BACKUP;
50
+ panTranslateY.value = (0, _utils.withAnimation)(0, () => {
51
+ pulldownState.value = _constants.PullingRefreshStatus.IDLE;
52
+ });
53
+ })();
54
+ };
55
+ const onPullupLoading = async () => {
56
+ const res = onPullupRefresh();
57
+ if ((0, _utils.isPromise)(res)) {
58
+ await res;
59
+ }
60
+ (0, _reactNativeReanimated.runOnUI)(() => {
61
+ 'worklet';
62
+
63
+ pullupState.value = _constants.PullingRefreshStatus.BACKUP;
64
+ panTranslateY.value = (0, _utils.withAnimation)(0, () => {
65
+ pullupState.value = _constants.PullingRefreshStatus.IDLE;
66
+ });
67
+ })();
68
+ };
69
+ const native = _reactNativeGestureHandler.Gesture.Native();
70
+ // FIXME: 响应有一个延时偏差,本来就很难搞呀
71
+ const panGesture = _reactNativeGestureHandler.Gesture.Pan().onStart(event => {
72
+ 'worklet';
73
+
74
+ // FIXME: Check Pull Status.
75
+ if (pulldownState.value >= _constants.PullingRefreshStatus.PULLINGBACK || pullupState.value >= _constants.PullingRefreshStatus.PULLINGBACK) {
76
+ return;
77
+ }
78
+ if (scrollerOffsetY.value <= _constants.SystemOffset && pulldownState.value === _constants.PullingRefreshStatus.IDLE && event.translationY > 0) {
79
+ pulldownState.value = _constants.PullingRefreshStatus.PULLING;
80
+ recordValue.value = event.translationY;
81
+ }
82
+ if (scrollerOffsetY.value <= contentY.value - containerY.value - _constants.SystemOffset && pullupState.value === _constants.PullingRefreshStatus.IDLE && event.translationY < 0) {
83
+ pullupState.value = _constants.PullingRefreshStatus.PULLING;
84
+ recordValue.value = event.translationY;
85
+ }
86
+
87
+ // eslint-disable-next-line no-console, @typescript-eslint/no-unused-expressions, @typescript-eslint/no-unnecessary-condition
88
+ _constants.LogFlag && console.log('onStart', pulldownState.value, pullupState.value);
89
+ }).onChange(event => {
90
+ 'worklet';
91
+
92
+ // when loading do nothing.
93
+ if (pulldownState.value >= _constants.PullingRefreshStatus.PULLINGBACK || pullupState.value >= _constants.PullingRefreshStatus.PULLINGBACK) {
94
+ return;
95
+ }
96
+
97
+ // pull down
98
+ if (event.translationY > 0) {
99
+ if (pullupState.value !== _constants.PullingRefreshStatus.IDLE) {
100
+ // FIXME: The delay released here will trigger the freezing of the bottom scroll,
101
+ // which is more obvious on Android than on iOS.
102
+ lockIDLE.value = 1;
103
+ pullupState.value = _constants.PullingRefreshStatus.IDLE;
104
+ }
105
+ if (scrollerOffsetY.value <= _constants.SystemOffset) {
106
+ const newStatus = (0, _utils.actuallyMove)(event.translationY, containerY.value) > pulldownHeight * pullingFactor ? _constants.PullingRefreshStatus.PULLINGGO : _constants.PullingRefreshStatus.PULLING;
107
+ if (newStatus !== pulldownState.value) {
108
+ if (pulldownState.value === _constants.PullingRefreshStatus.IDLE) {
109
+ recordValue.value = event.translationY;
110
+ }
111
+ pulldownState.value = newStatus;
112
+ }
113
+ const move = event.translationY - recordValue.value;
114
+ if (move < 0) {
115
+ pulldownState.value = _constants.PullingRefreshStatus.IDLE;
116
+ } else {
117
+ panTranslateY.value = move;
118
+ }
119
+ }
120
+ }
121
+
122
+ // FIXME: release switch has an issue.
123
+ if (event.translationY < 0) {
124
+ // up
125
+ if (pulldownState.value !== _constants.PullingRefreshStatus.IDLE) {
126
+ lockIDLE.value = 1;
127
+ pulldownState.value = _constants.PullingRefreshStatus.IDLE;
128
+ }
129
+
130
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions, @typescript-eslint/no-unnecessary-condition
131
+ _constants.LogFlag &&
132
+ // eslint-disable-next-line no-console
133
+ console.log('onChangeBottom', scrollerOffsetY.value >= contentY.value - containerY.value - _constants.SystemOffset);
134
+ if (scrollerOffsetY.value >= contentY.value - containerY.value - _constants.SystemOffset) {
135
+ const newStatus = (0, _utils.actuallyMove)(-event.translationY, containerY.value) > pullupHeight * pullingFactor ? _constants.PullingRefreshStatus.PULLINGGO : _constants.PullingRefreshStatus.PULLING;
136
+ if (newStatus !== pullupState.value) {
137
+ // TODO: 个人感觉是这个值记录得有问题
138
+ if (pullupState.value === _constants.PullingRefreshStatus.IDLE) {
139
+ recordValue.value = event.translationY;
140
+ }
141
+ pullupState.value = newStatus;
142
+ }
143
+ const move = event.translationY - recordValue.value;
144
+
145
+ // if (move > 0) {
146
+ // pullupState.value = PullingRefreshStatus.IDLE;
147
+ // } else {
148
+ panTranslateY.value = move;
149
+ // }
150
+ }
151
+ }
152
+ if (lockIDLE.value) {
153
+ lockIDLE.value = 0;
154
+ }
155
+
156
+ // FIXME: when fast move, need recheck it
157
+
158
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions, @typescript-eslint/no-unnecessary-condition
159
+ _constants.LogFlag &&
160
+ // eslint-disable-next-line no-console
161
+ console.log('onChange-value', scrollerOffsetY.value, contentY.value - containerY.value, contentY.value, containerY.value, scrollerOffsetY.value - (contentY.value - containerY.value));
162
+
163
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions, @typescript-eslint/no-unnecessary-condition
164
+ _constants.LogFlag &&
165
+ // eslint-disable-next-line no-console
166
+ console.log('onChange', pulldownState.value, pullupState.value);
167
+ }).onEnd(() => {
168
+ 'worklet';
169
+
170
+ if (pulldownState.value >= _constants.PullingRefreshStatus.PULLINGBACK || pullupState.value >= _constants.PullingRefreshStatus.PULLINGBACK) {
171
+ return;
172
+ }
173
+
174
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions, @typescript-eslint/no-unnecessary-condition
175
+ _constants.LogFlag &&
176
+ // eslint-disable-next-line no-console
177
+ console.log(scrollerOffsetY.value >= contentY.value - containerY.value - _constants.SystemOffset);
178
+ if (scrollerOffsetY.value <= _constants.SystemOffset) {
179
+ if (pulldownState.value !== _constants.PullingRefreshStatus.IDLE) {
180
+ pulldownState.value = panTranslateY.value >= pulldownHeight * pullingFactor ? _constants.PullingRefreshStatus.PULLINGBACK : _constants.PullingRefreshStatus.BACKUP;
181
+ if (pulldownState.value === _constants.PullingRefreshStatus.BACKUP) {
182
+ panTranslateY.value = (0, _utils.withAnimation)(0, () => {
183
+ pulldownState.value = _constants.PullingRefreshStatus.IDLE;
184
+ });
185
+ }
186
+ if (pulldownState.value === _constants.PullingRefreshStatus.PULLINGBACK) {
187
+ panTranslateY.value = (0, _utils.withAnimation)(pulldownHeight, () => {
188
+ pulldownState.value = _constants.PullingRefreshStatus.LOADING;
189
+ (0, _reactNativeReanimated.runOnJS)(onPulldownLoading)();
190
+ });
191
+ }
192
+ }
193
+ }
194
+ if (scrollerOffsetY.value >= contentY.value - containerY.value - _constants.SystemOffset) {
195
+ if (pullupState.value !== _constants.PullingRefreshStatus.IDLE) {
196
+ pullupState.value = -panTranslateY.value >= pullupHeight * pullingFactor ? _constants.PullingRefreshStatus.PULLINGBACK : _constants.PullingRefreshStatus.BACKUP;
197
+ if (pullupState.value === _constants.PullingRefreshStatus.BACKUP) {
198
+ panTranslateY.value = (0, _utils.withAnimation)(0, () => {
199
+ pullupState.value = _constants.PullingRefreshStatus.IDLE;
200
+ });
201
+ }
202
+ if (pullupState.value === _constants.PullingRefreshStatus.PULLINGBACK) {
203
+ panTranslateY.value = (0, _utils.withAnimation)(-pullupHeight, () => {
204
+ pullupState.value = _constants.PullingRefreshStatus.LOADING;
205
+ (0, _reactNativeReanimated.runOnJS)(onPullupLoading)();
206
+ });
207
+ }
208
+ }
209
+ }
210
+ if (scrollerOffsetY.value >= _constants.SystemOffset && scrollerOffsetY.value <= contentY.value - containerY.value - _constants.SystemOffset) {
211
+ if (pulldownState.value !== _constants.PullingRefreshStatus.IDLE) {
212
+ pulldownState.value = _constants.PullingRefreshStatus.IDLE;
213
+ }
214
+ if (pullupState.value !== _constants.PullingRefreshStatus.IDLE) {
215
+ pullupState.value = _constants.PullingRefreshStatus.IDLE;
216
+ }
217
+ }
218
+
219
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions, @typescript-eslint/no-unnecessary-condition
220
+ _constants.LogFlag &&
221
+ // eslint-disable-next-line no-console
222
+ console.log('onEnd-value', scrollerOffsetY.value, contentY.value - containerY.value, contentY.value, containerY.value, scrollerOffsetY.value - (contentY.value - containerY.value));
223
+
224
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions, @typescript-eslint/no-unnecessary-condition, no-console
225
+ _constants.LogFlag && console.log('onEnd', pulldownState.value, pullupState.value);
226
+ });
227
+ const contentAnimation = (0, _reactNativeReanimated.useAnimatedStyle)(() => {
228
+ const isPulldown = pulldownState.value !== _constants.PullingRefreshStatus.IDLE;
229
+ let input = [0, pulldownHeight, containerY.value];
230
+ let output = [0, pulldownHeight, containerY.value * containerFactor];
231
+ if (!isPulldown) {
232
+ input = [-containerY.value, -pullupHeight, 0];
233
+ output = [-containerY.value * containerFactor, -pullupHeight, 0];
234
+ }
235
+ return {
236
+ /**
237
+ * FIXME: #issue 👀
238
+ * Pullup to bounce back failed during the quick move down to up
239
+ * at the bottom on ios and android simulator.
240
+ * However, it works fine on the real device.
241
+ * Maybe the simulator cant tracking gestures by mouse normally.
242
+ * */
243
+ overflowY: /* for web */
244
+ pullupState.value !== _constants.PullingRefreshStatus.IDLE || pulldownState.value !== _constants.PullingRefreshStatus.IDLE || lockIDLE.value ? 'hidden' : 'auto',
245
+ pointerEvents: pullupState.value !== _constants.PullingRefreshStatus.IDLE || pulldownState.value !== _constants.PullingRefreshStatus.IDLE || lockIDLE.value ? 'none' : 'auto',
246
+ transform: [{
247
+ translateY: (0, _reactNativeReanimated.interpolate)(panTranslateY.value, input, output, _reactNativeReanimated.Extrapolate.CLAMP)
248
+ }]
249
+ };
250
+ });
251
+ const onScroll = (0, _reactNativeReanimated.useAnimatedScrollHandler)(event => {
252
+ // FIXME: 下拉刷新是一定依赖这个数据值的,不然你无法处理的
253
+ scrollerOffsetY.value = event.contentOffset.y;
254
+ // LogFlag && console.log('onScroll', event.contentOffset);
255
+
256
+ const _children = children;
257
+ // @ts-ignore
258
+ if (_children?.props?.onScroll) {
259
+ // @ts-ignore
260
+ (0, _reactNativeReanimated.runOnJS)(_children?.props?.onScroll)(event);
261
+ }
262
+ });
263
+ const onLayout = (0, _react.useCallback)(event => {
264
+ containerY.value = event.nativeEvent.layout.height;
265
+ }, [containerY]);
266
+ const onContentSizeChange = (0, _react.useCallback)((_width, height) => {
267
+ contentY.value = height;
268
+
269
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
270
+ // @ts-ignore
271
+ if (children.onContentSizeChange) {
272
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
273
+ // @ts-ignore
274
+ children.onContentSizeChange(event);
275
+ }
276
+ }, [contentY, children]);
277
+ const childStyle = [_reactNative.StyleSheet.absoluteFill, styles.zTop,
278
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
279
+ // @ts-ignore
280
+ children?.props?.style, contentAnimation];
281
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_context.MrPullRefreshContext.Provider, {
282
+ value: {
283
+ pulldownState,
284
+ pullupState,
285
+ panTranslateY,
286
+ scrollerOffsetY,
287
+ contentY,
288
+ containerY,
289
+ pulldownHeight,
290
+ pullupHeight,
291
+ pullingFactor,
292
+ containerFactor
293
+ },
294
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
295
+ style: [styles.flex, styles.overhidden, style],
296
+ children: [pulldownLoading, /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector, {
297
+ gesture: _reactNativeGestureHandler.Gesture.Simultaneous(panGesture, native),
298
+ children: /*#__PURE__*/_react.default.cloneElement((0, _utils.checkChildren)(children), {
299
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
300
+ // @ts-ignore
301
+ onContentSizeChange,
302
+ onScroll,
303
+ bounces: false,
304
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
305
+ // @ts-ignore
306
+ style: childStyle,
307
+ scrollEventThrottle: 16,
308
+ onLayout
309
+ })
310
+ }), pullupEnabled && pullupLoading]
311
+ })
312
+ });
313
+ };
314
+ const styles = _reactNative.StyleSheet.create({
315
+ flex: {
316
+ flex: 1
317
+ },
318
+ zTop: {
319
+ zIndex: 2
320
+ },
321
+ overhidden: {
322
+ overflow: 'hidden'
323
+ }
324
+ });
325
+ const PullRefresh = exports.PullRefresh = /*#__PURE__*/(0, _react.memo)(RefreshWrapper);
326
+ //# sourceMappingURL=PullRefresh.js.map