@btndprojects/loam-ui-native 0.0.0-stage → 0.1.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.
- package/LICENSE +21 -0
- package/dist/accordion/index.js +3 -0
- package/dist/adaptive/index.js +2 -0
- package/dist/alert/index.js +3 -0
- package/dist/analyzer/index.js +6 -0
- package/dist/announcement/index.js +6 -0
- package/dist/audio-player/index.js +3 -0
- package/dist/avatar/index.js +3 -0
- package/dist/avatar-group/index.js +3 -0
- package/dist/badge/index.js +5 -0
- package/dist/banner/index.js +2 -0
- package/dist/board/index.js +7 -0
- package/dist/button/index.js +5 -0
- package/dist/camera-permission/index.js +13 -0
- package/dist/capture-result/index.js +18 -0
- package/dist/card/index.js +4 -0
- package/dist/card-form/index.js +10 -0
- package/dist/carousel/index.js +2 -0
- package/dist/chart/index.js +6 -0
- package/dist/charts/index.js +7 -0
- package/dist/checkbox/index.js +7 -0
- package/dist/checklist/index.js +10 -0
- package/dist/checkout/index.js +13 -0
- package/dist/chip/index.js +7 -0
- package/dist/chunk-223Q2T2Q.js +229 -0
- package/dist/chunk-2A5NIQAK.js +254 -0
- package/dist/chunk-2GK6PHGE.js +363 -0
- package/dist/chunk-2WUTXHMU.js +1 -0
- package/dist/chunk-2ZZ7TDJ4.js +324 -0
- package/dist/chunk-35OFI3JG.js +499 -0
- package/dist/chunk-3ARE4TES.js +195 -0
- package/dist/chunk-3ECPOSKO.js +1 -0
- package/dist/chunk-3ENTMPQY.js +229 -0
- package/dist/chunk-3HJH6FF4.js +98 -0
- package/dist/chunk-3NMD74ZU.js +4 -0
- package/dist/chunk-3WPW4KUN.js +182 -0
- package/dist/chunk-47FWHGUN.js +394 -0
- package/dist/chunk-4BXMXBJO.js +141 -0
- package/dist/chunk-4DS5ZWVC.js +83 -0
- package/dist/chunk-4GBOGOTV.js +295 -0
- package/dist/chunk-4SZYY6AN.js +99 -0
- package/dist/chunk-4YIP3CWS.js +237 -0
- package/dist/chunk-4YQOR7JM.js +204 -0
- package/dist/chunk-4ZAHCY44.js +177 -0
- package/dist/chunk-52X2VYTD.js +228 -0
- package/dist/chunk-5P26LBDL.js +1 -0
- package/dist/chunk-5XLRYDAX.js +1 -0
- package/dist/chunk-5YNTNN5A.js +177 -0
- package/dist/chunk-66SG2H23.js +129 -0
- package/dist/chunk-6HT2LP62.js +504 -0
- package/dist/chunk-6N33LFQA.js +35 -0
- package/dist/chunk-6X6PQ443.js +432 -0
- package/dist/chunk-7CFF4HXS.js +126 -0
- package/dist/chunk-7O2FMUPT.js +755 -0
- package/dist/chunk-AI4DWZCD.js +162 -0
- package/dist/chunk-AWJOCGFZ.js +213 -0
- package/dist/chunk-AZRX6SAC.js +285 -0
- package/dist/chunk-B54QE2FN.js +1 -0
- package/dist/chunk-BC475SJH.js +1 -0
- package/dist/chunk-BEDBFJND.js +202 -0
- package/dist/chunk-BTTFCMKG.js +166 -0
- package/dist/chunk-BV3B2HYZ.js +1635 -0
- package/dist/chunk-C2NTXVWM.js +98 -0
- package/dist/chunk-CDRZHT42.js +424 -0
- package/dist/chunk-CJ5EOYZE.js +62 -0
- package/dist/chunk-CUMUNPXY.js +128 -0
- package/dist/chunk-CUS3ZSCU.js +1 -0
- package/dist/chunk-CYRBHQQZ.js +411 -0
- package/dist/chunk-DHWADYZX.js +144 -0
- package/dist/chunk-DKCSPATL.js +1 -0
- package/dist/chunk-DM5QUKKO.js +326 -0
- package/dist/chunk-DSJBXLUG.js +845 -0
- package/dist/chunk-DYBH2I6W.js +1 -0
- package/dist/chunk-DZ255O2F.js +1 -0
- package/dist/chunk-E35BPSGW.js +1 -0
- package/dist/chunk-EJBDRVIH.js +166 -0
- package/dist/chunk-F43NP42L.js +1 -0
- package/dist/chunk-F5XNPWS7.js +1024 -0
- package/dist/chunk-FIF2M24N.js +1521 -0
- package/dist/chunk-FOKG57CR.js +993 -0
- package/dist/chunk-G3HOYSF7.js +1 -0
- package/dist/chunk-GDKZTW34.js +395 -0
- package/dist/chunk-GL7B2DOW.js +134 -0
- package/dist/chunk-GNNJ4GCC.js +471 -0
- package/dist/chunk-GNZ56EUI.js +1 -0
- package/dist/chunk-H6NIOQHK.js +346 -0
- package/dist/chunk-H6PC7RDA.js +1 -0
- package/dist/chunk-HPPW424V.js +334 -0
- package/dist/chunk-HQOQIBJI.js +1 -0
- package/dist/chunk-HU2EQNRZ.js +44 -0
- package/dist/chunk-IIQTAY3J.js +715 -0
- package/dist/chunk-ITTYJZWX.js +271 -0
- package/dist/chunk-IVNRBPGC.js +1018 -0
- package/dist/chunk-J4KLDGI4.js +1 -0
- package/dist/chunk-J7Q7VCVC.js +254 -0
- package/dist/chunk-JDEOITQ2.js +1 -0
- package/dist/chunk-JNH2TYIN.js +96 -0
- package/dist/chunk-JRLTGLN4.js +1 -0
- package/dist/chunk-JTRJJLKL.js +1 -0
- package/dist/chunk-JUAMLEHX.js +379 -0
- package/dist/chunk-JXJB2X6M.js +131 -0
- package/dist/chunk-KMI5ML5I.js +262 -0
- package/dist/chunk-KTAC4MGE.js +4 -0
- package/dist/chunk-LAECSR4H.js +178 -0
- package/dist/chunk-LK4BCSGX.js +1 -0
- package/dist/chunk-LOE5YNN3.js +470 -0
- package/dist/chunk-LRJNDEIA.js +302 -0
- package/dist/chunk-LSS54GLJ.js +116 -0
- package/dist/chunk-LZLHELAG.js +137 -0
- package/dist/chunk-M2LUXGKZ.js +1 -0
- package/dist/chunk-MOUJOP55.js +425 -0
- package/dist/chunk-N32RGOA5.js +159 -0
- package/dist/chunk-N5ZNE2YE.js +1 -0
- package/dist/chunk-NBNCBML6.js +1 -0
- package/dist/chunk-NKB7BZYK.js +167 -0
- package/dist/chunk-NQYBUO3K.js +1795 -0
- package/dist/chunk-NY2U3PBI.js +59 -0
- package/dist/chunk-O4AEHWII.js +464 -0
- package/dist/chunk-O7AE6DAF.js +146 -0
- package/dist/chunk-OETCUXQP.js +134 -0
- package/dist/chunk-OOPPQH27.js +179 -0
- package/dist/chunk-OPXFZ4Y5.js +204 -0
- package/dist/chunk-P23EQNRQ.js +338 -0
- package/dist/chunk-PJXUJYS6.js +248 -0
- package/dist/chunk-PNWUWOBF.js +1 -0
- package/dist/chunk-PUPM2YGF.js +376 -0
- package/dist/chunk-PZXZJBMP.js +620 -0
- package/dist/chunk-Q72LJOVE.js +169 -0
- package/dist/chunk-QCDXZBC5.js +247 -0
- package/dist/chunk-QDYDBCFP.js +197 -0
- package/dist/chunk-QJJ6MADV.js +274 -0
- package/dist/chunk-QKXCPTFS.js +349 -0
- package/dist/chunk-QWCMU5B2.js +860 -0
- package/dist/chunk-RGQWWKLA.js +634 -0
- package/dist/chunk-RIBDXGUG.js +108 -0
- package/dist/chunk-RJQOOHT2.js +214 -0
- package/dist/chunk-RNGLIHFA.js +191 -0
- package/dist/chunk-RQ3HASCC.js +6 -0
- package/dist/chunk-RSOJT5YW.js +124 -0
- package/dist/chunk-RTIKSY6A.js +1 -0
- package/dist/chunk-RUZHTGKB.js +237 -0
- package/dist/chunk-RW6ZL2FQ.js +284 -0
- package/dist/chunk-S7F6XLTK.js +540 -0
- package/dist/chunk-SBMNWWBV.js +155 -0
- package/dist/chunk-SDTQPRRB.js +1 -0
- package/dist/chunk-SYNOJOQO.js +377 -0
- package/dist/chunk-T753XT36.js +1 -0
- package/dist/chunk-TKQYWZ5V.js +196 -0
- package/dist/chunk-TKVFVF5D.js +95 -0
- package/dist/chunk-TOXAGRDQ.js +144 -0
- package/dist/chunk-TUTI5HOZ.js +112 -0
- package/dist/chunk-U7TFM2JA.js +140 -0
- package/dist/chunk-UC2WGUP3.js +627 -0
- package/dist/chunk-UWFLYMAR.js +1126 -0
- package/dist/chunk-UWSZB7BJ.js +1 -0
- package/dist/chunk-UYG5L34B.js +87 -0
- package/dist/chunk-VBOXAEPI.js +336 -0
- package/dist/chunk-VCDBXW5H.js +188 -0
- package/dist/chunk-VCXPHHDS.js +1 -0
- package/dist/chunk-VEAYTRPX.js +414 -0
- package/dist/chunk-VFCUIDRT.js +1 -0
- package/dist/chunk-VQHPQEUH.js +273 -0
- package/dist/chunk-VXDZFJGP.js +874 -0
- package/dist/chunk-WS56BL3D.js +1 -0
- package/dist/chunk-WSW6ZFAQ.js +98 -0
- package/dist/chunk-WVKKJA6U.js +870 -0
- package/dist/chunk-XNUVB5OL.js +375 -0
- package/dist/chunk-XOSCY2CW.js +242 -0
- package/dist/chunk-XXXEFXY5.js +99 -0
- package/dist/chunk-Y5CSSPV4.js +1 -0
- package/dist/chunk-Y6DU4J47.js +1 -0
- package/dist/chunk-YC6WORFL.js +535 -0
- package/dist/chunk-YDGVJETP.js +60 -0
- package/dist/chunk-YF4NSSMT.js +366 -0
- package/dist/chunk-YG3ZJHGU.js +223 -0
- package/dist/chunk-YIJ55TBC.js +1 -0
- package/dist/chunk-YKZ4RZZF.js +1 -0
- package/dist/chunk-YLLCXTMC.js +37 -0
- package/dist/chunk-YTA74UZR.js +1 -0
- package/dist/chunk-Z7H7VSFZ.js +323 -0
- package/dist/chunk-ZK2H4O5P.js +1 -0
- package/dist/chunk-ZVFE5QGU.js +524 -0
- package/dist/coachmark/index.js +4 -0
- package/dist/code-block/index.js +4 -0
- package/dist/color-field/index.js +7 -0
- package/dist/commerce/index.js +20 -0
- package/dist/connectivity/index.js +2 -0
- package/dist/context-menu/index.js +5 -0
- package/dist/copy-button/index.js +3 -0
- package/dist/data-grid/index.js +24 -0
- package/dist/date-range-picker/index.js +13 -0
- package/dist/description-list/index.js +2 -0
- package/dist/dialog/index.js +3 -0
- package/dist/empty-state/index.js +3 -0
- package/dist/error-summary/index.js +3 -0
- package/dist/fab/index.js +2 -0
- package/dist/file-upload/index.js +9 -0
- package/dist/filter-bar/index.js +8 -0
- package/dist/flow-run/index.js +14 -0
- package/dist/form/index.js +3 -0
- package/dist/gallery/index.js +2 -0
- package/dist/header/index.js +5 -0
- package/dist/hold-to-confirm/index.js +4 -0
- package/dist/index.d.ts +22883 -0
- package/dist/index.js +158 -0
- package/dist/infinite-list/index.js +2 -0
- package/dist/inline-edit/index.js +5 -0
- package/dist/input/index.js +5 -0
- package/dist/interactions/index.js +2 -0
- package/dist/invoice/index.js +10 -0
- package/dist/kbd/index.js +1 -0
- package/dist/keyboard/index.js +3 -0
- package/dist/list-row/index.js +7 -0
- package/dist/log-viewer/index.js +2 -0
- package/dist/map-view/index.js +3 -0
- package/dist/markdown/index.js +6 -0
- package/dist/metric/index.js +4 -0
- package/dist/money/index.js +3 -0
- package/dist/nav-drawer/index.js +2 -0
- package/dist/navigation/index.js +2 -0
- package/dist/notification-center/index.js +16 -0
- package/dist/number-roll/index.js +3 -0
- package/dist/one-handed/index.js +5 -0
- package/dist/os-surfaces/index.js +3 -0
- package/dist/otp/index.js +7 -0
- package/dist/page-header/index.js +1 -0
- package/dist/payment-method/index.js +12 -0
- package/dist/payment-status/index.js +16 -0
- package/dist/permission/index.js +2 -0
- package/dist/picker/index.js +7 -0
- package/dist/progress/index.js +5 -0
- package/dist/pull-to-refresh/index.js +4 -0
- package/dist/radio-group/index.js +6 -0
- package/dist/rating/index.js +2 -0
- package/dist/receivables/index.js +20 -0
- package/dist/refund/index.js +16 -0
- package/dist/save-status/index.js +3 -0
- package/dist/scroll-area/index.js +1 -0
- package/dist/search-bar/index.js +5 -0
- package/dist/segmented-control/index.js +5 -0
- package/dist/sheet/index.js +4 -0
- package/dist/skeleton/index.js +2 -0
- package/dist/slider/index.js +5 -0
- package/dist/spinner/index.js +2 -0
- package/dist/split-button/index.js +7 -0
- package/dist/spotlight/index.js +2 -0
- package/dist/stage-timeline/index.js +4 -0
- package/dist/status-dot/index.js +2 -0
- package/dist/stepper/index.js +6 -0
- package/dist/streaming-text/index.js +3 -0
- package/dist/survey/index.js +19 -0
- package/dist/switch/index.js +5 -0
- package/dist/system-state/index.js +4 -0
- package/dist/tab-bar/index.js +2 -0
- package/dist/tabs/index.js +2 -0
- package/dist/textarea/index.js +6 -0
- package/dist/thinking/index.js +2 -0
- package/dist/timeline/index.js +4 -0
- package/dist/toast/index.js +2 -0
- package/dist/toolbar/index.js +2 -0
- package/dist/tour/index.js +11 -0
- package/dist/truncation-notice/index.js +2 -0
- package/dist/update-notice/index.js +11 -0
- package/dist/video-player/index.js +2 -0
- package/dist/viewfinder/index.js +5 -0
- package/dist/widget/index.js +4 -0
- package/dist/wizard/index.js +6 -0
- package/package.json +76 -3
- package/README.md +0 -3
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
import { MAX_OVERSCROLL_PX, REFRESH_ARM_PX, SCROLL_TOP_SLOP_PX, overscrollOffset, overscrollIntent } from './chunk-HU2EQNRZ.js';
|
|
2
|
+
import { haptics } from './chunk-NY2U3PBI.js';
|
|
3
|
+
import { Icon } from './chunk-TKVFVF5D.js';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import { Animated, Easing, View, Text, Pressable, ScrollView } from 'react-native';
|
|
6
|
+
import { createStyleSheet, useStyles, useLoamTheme } from '@btndprojects/loam-theme-native';
|
|
7
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
8
|
+
|
|
9
|
+
function touchPageY(e) {
|
|
10
|
+
const ne = e.nativeEvent;
|
|
11
|
+
if (typeof ne.pageY === "number") return ne.pageY;
|
|
12
|
+
const touch = ne.touches?.[0] ?? ne.changedTouches?.[0];
|
|
13
|
+
return typeof touch?.pageY === "number" ? touch.pageY : null;
|
|
14
|
+
}
|
|
15
|
+
function isThenable(v) {
|
|
16
|
+
return typeof v?.then === "function";
|
|
17
|
+
}
|
|
18
|
+
function PullToRefresh({
|
|
19
|
+
onRefresh,
|
|
20
|
+
onArm,
|
|
21
|
+
refreshing,
|
|
22
|
+
phase,
|
|
23
|
+
indicator,
|
|
24
|
+
armLabel = "Release to refresh",
|
|
25
|
+
refreshingLabel = "Refreshing",
|
|
26
|
+
refreshAccessibilityLabel = "Refresh",
|
|
27
|
+
children,
|
|
28
|
+
...rest
|
|
29
|
+
}) {
|
|
30
|
+
const { styles } = useStyles(sheet);
|
|
31
|
+
const theme = useLoamTheme();
|
|
32
|
+
const isAndroid = (indicator ?? (theme.platform === "Android" ? "android" : "ios")) === "android";
|
|
33
|
+
const reduce = theme.reduceMotion;
|
|
34
|
+
const controlled = phase != null;
|
|
35
|
+
const [ownRefreshing, setOwnRefreshing] = React.useState(false);
|
|
36
|
+
const isRefreshing = refreshing ?? ownRefreshing;
|
|
37
|
+
const [armed, setArmed] = React.useState(false);
|
|
38
|
+
const armedRef = React.useRef(false);
|
|
39
|
+
const displayRefreshing = controlled ? phase === "refreshing" : isRefreshing;
|
|
40
|
+
const displayArmed = controlled ? phase === "armed" : armed && !isRefreshing;
|
|
41
|
+
const statusText = displayRefreshing ? refreshingLabel : displayArmed ? armLabel : "";
|
|
42
|
+
const showText = statusText !== "";
|
|
43
|
+
const ringSize = theme.icon.lg;
|
|
44
|
+
const clearance = theme.space.s3;
|
|
45
|
+
const spinnerBox = isAndroid ? ringSize + clearance * 2 : ringSize;
|
|
46
|
+
const gap = theme.space.s2;
|
|
47
|
+
const textBlockH = theme.icon.md + theme.space.s1 * 2;
|
|
48
|
+
const chromeH = spinnerBox + (showText ? gap + textBlockH : 0);
|
|
49
|
+
const holdOffset = Math.min(spinnerBox + gap + textBlockH + clearance * 2, MAX_OVERSCROLL_PX);
|
|
50
|
+
const offset = React.useRef(new Animated.Value(0)).current;
|
|
51
|
+
const spin = React.useRef(new Animated.Value(0)).current;
|
|
52
|
+
const scrollTop = React.useRef(0);
|
|
53
|
+
const startY = React.useRef(null);
|
|
54
|
+
const band = React.useRef(0);
|
|
55
|
+
React.useEffect(() => {
|
|
56
|
+
if (!displayRefreshing || reduce) {
|
|
57
|
+
spin.setValue(0);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const loop = Animated.loop(
|
|
61
|
+
Animated.sequence([
|
|
62
|
+
Animated.timing(spin, {
|
|
63
|
+
toValue: 1,
|
|
64
|
+
duration: theme.loop.spin,
|
|
65
|
+
easing: Easing.linear,
|
|
66
|
+
useNativeDriver: true
|
|
67
|
+
})
|
|
68
|
+
])
|
|
69
|
+
);
|
|
70
|
+
loop.start();
|
|
71
|
+
return () => loop.stop();
|
|
72
|
+
}, [displayRefreshing, spin, theme.loop.spin, reduce]);
|
|
73
|
+
const settle = React.useCallback(
|
|
74
|
+
(to) => (
|
|
75
|
+
// `motion.exit` closing, `motion.enter` opening — exit is always faster.
|
|
76
|
+
Animated.timing(offset, {
|
|
77
|
+
toValue: to,
|
|
78
|
+
duration: to === 0 ? theme.motion.exit.duration : theme.motion.enter.duration,
|
|
79
|
+
easing: Easing.bezier(...to === 0 ? theme.motion.exit.easing : theme.motion.enter.easing),
|
|
80
|
+
useNativeDriver: true
|
|
81
|
+
}).start()
|
|
82
|
+
),
|
|
83
|
+
[offset, theme.motion.enter, theme.motion.exit]
|
|
84
|
+
);
|
|
85
|
+
React.useEffect(() => {
|
|
86
|
+
if (!controlled) return;
|
|
87
|
+
const target = phase === "idle" ? 0 : phase === "pulling" ? Math.min(REFRESH_ARM_PX * 0.6, holdOffset) : holdOffset;
|
|
88
|
+
offset.setValue(target);
|
|
89
|
+
}, [controlled, phase, holdOffset, offset]);
|
|
90
|
+
React.useEffect(() => {
|
|
91
|
+
if (controlled) return;
|
|
92
|
+
if (reduce) settle(isRefreshing || armed ? holdOffset : 0);
|
|
93
|
+
else settle(isRefreshing ? holdOffset : 0);
|
|
94
|
+
}, [controlled, reduce, isRefreshing, armed, holdOffset, settle]);
|
|
95
|
+
const setArmedState = (next) => {
|
|
96
|
+
if (next === armedRef.current) return;
|
|
97
|
+
armedRef.current = next;
|
|
98
|
+
setArmed(next);
|
|
99
|
+
if (next) {
|
|
100
|
+
haptics.impact("light");
|
|
101
|
+
onArm?.();
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
const beginRefresh = React.useCallback(() => {
|
|
105
|
+
const result = onRefresh?.();
|
|
106
|
+
if (refreshing == null && isThenable(result)) {
|
|
107
|
+
setOwnRefreshing(true);
|
|
108
|
+
const done = () => setOwnRefreshing(false);
|
|
109
|
+
void result.then(done, done);
|
|
110
|
+
settle(holdOffset);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
settle(0);
|
|
114
|
+
}, [onRefresh, refreshing, holdOffset, settle]);
|
|
115
|
+
const onTouchStart = (e) => {
|
|
116
|
+
if (controlled) return;
|
|
117
|
+
const y = touchPageY(e);
|
|
118
|
+
if (y != null && scrollTop.current <= SCROLL_TOP_SLOP_PX && !isRefreshing) startY.current = y;
|
|
119
|
+
};
|
|
120
|
+
const onTouchMove = (e) => {
|
|
121
|
+
if (controlled || startY.current == null) return;
|
|
122
|
+
const y = touchPageY(e);
|
|
123
|
+
if (y == null) return;
|
|
124
|
+
band.current = overscrollOffset(y - startY.current);
|
|
125
|
+
setArmedState(band.current > REFRESH_ARM_PX);
|
|
126
|
+
if (!reduce) offset.setValue(band.current);
|
|
127
|
+
};
|
|
128
|
+
const onTouchEnd = () => {
|
|
129
|
+
if (controlled || startY.current == null) return;
|
|
130
|
+
startY.current = null;
|
|
131
|
+
const intent = overscrollIntent(band.current, { refresh: true });
|
|
132
|
+
band.current = 0;
|
|
133
|
+
setArmedState(false);
|
|
134
|
+
if (intent !== "refresh" || isRefreshing) {
|
|
135
|
+
settle(0);
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
beginRefresh();
|
|
139
|
+
};
|
|
140
|
+
const chromeY = reduce ? 0 : Animated.subtract(Animated.multiply(offset, 0.5), chromeH / 2);
|
|
141
|
+
const revealIn = Math.max(1, chromeH * 0.6);
|
|
142
|
+
const revealFull = Math.max(revealIn + 1, chromeH + clearance);
|
|
143
|
+
const reveal = offset.interpolate({
|
|
144
|
+
inputRange: [0, revealIn, revealFull],
|
|
145
|
+
outputRange: [0, 0, 1],
|
|
146
|
+
extrapolate: "clamp"
|
|
147
|
+
});
|
|
148
|
+
const chromeScale = reduce ? 1 : reveal;
|
|
149
|
+
const rotate = reduce ? "0deg" : Animated.add(
|
|
150
|
+
// The ring winds up with the drag, then the loop takes over.
|
|
151
|
+
offset.interpolate({
|
|
152
|
+
inputRange: [0, MAX_OVERSCROLL_PX],
|
|
153
|
+
outputRange: [0, 440],
|
|
154
|
+
extrapolate: "clamp"
|
|
155
|
+
}),
|
|
156
|
+
spin.interpolate({ inputRange: [0, 1], outputRange: [0, 360] })
|
|
157
|
+
).interpolate({ inputRange: [0, 360], outputRange: ["0deg", "360deg"] });
|
|
158
|
+
return /* @__PURE__ */ jsxs(View, { style: styles.root, children: [
|
|
159
|
+
/* @__PURE__ */ jsxs(
|
|
160
|
+
Animated.View,
|
|
161
|
+
{
|
|
162
|
+
style: [
|
|
163
|
+
styles.chrome,
|
|
164
|
+
{ opacity: reveal, transform: [{ translateY: chromeY }, { scale: chromeScale }] }
|
|
165
|
+
],
|
|
166
|
+
children: [
|
|
167
|
+
/* @__PURE__ */ jsx(
|
|
168
|
+
View,
|
|
169
|
+
{
|
|
170
|
+
accessibilityElementsHidden: true,
|
|
171
|
+
importantForAccessibility: "no-hide-descendants",
|
|
172
|
+
"aria-hidden": true,
|
|
173
|
+
style: [
|
|
174
|
+
styles.spinnerBox,
|
|
175
|
+
isAndroid ? styles.spinnerBoxAndroid : null,
|
|
176
|
+
{ width: spinnerBox, height: spinnerBox }
|
|
177
|
+
],
|
|
178
|
+
children: /* @__PURE__ */ jsx(
|
|
179
|
+
Animated.View,
|
|
180
|
+
{
|
|
181
|
+
style: [
|
|
182
|
+
styles.ring,
|
|
183
|
+
{
|
|
184
|
+
width: ringSize,
|
|
185
|
+
height: ringSize,
|
|
186
|
+
borderWidth: theme.icon.strokeBold,
|
|
187
|
+
transform: [{ rotate }]
|
|
188
|
+
}
|
|
189
|
+
]
|
|
190
|
+
}
|
|
191
|
+
)
|
|
192
|
+
}
|
|
193
|
+
),
|
|
194
|
+
/* @__PURE__ */ jsx(
|
|
195
|
+
View,
|
|
196
|
+
{
|
|
197
|
+
accessibilityRole: "text",
|
|
198
|
+
role: "status",
|
|
199
|
+
accessibilityLiveRegion: "polite",
|
|
200
|
+
accessibilityState: { busy: displayRefreshing },
|
|
201
|
+
style: showText ? [styles.status, { marginTop: gap }] : styles.statusHidden,
|
|
202
|
+
children: showText ? /* @__PURE__ */ jsx(Text, { style: styles.statusText, children: statusText }) : null
|
|
203
|
+
}
|
|
204
|
+
)
|
|
205
|
+
]
|
|
206
|
+
}
|
|
207
|
+
),
|
|
208
|
+
/* @__PURE__ */ jsx(
|
|
209
|
+
Pressable,
|
|
210
|
+
{
|
|
211
|
+
onPress: isRefreshing ? void 0 : beginRefresh,
|
|
212
|
+
accessibilityRole: "button",
|
|
213
|
+
accessibilityLabel: refreshAccessibilityLabel,
|
|
214
|
+
accessibilityState: { busy: isRefreshing, disabled: isRefreshing },
|
|
215
|
+
"aria-busy": isRefreshing || void 0,
|
|
216
|
+
hitSlop: theme.space.s2,
|
|
217
|
+
style: styles.refreshButton,
|
|
218
|
+
children: /* @__PURE__ */ jsx(Icon, { name: "refresh", size: theme.icon.sm, color: theme.color.text })
|
|
219
|
+
}
|
|
220
|
+
),
|
|
221
|
+
/* @__PURE__ */ jsx(Animated.View, { style: [styles.content, { transform: [{ translateY: offset }] }], children: /* @__PURE__ */ jsx(
|
|
222
|
+
ScrollView,
|
|
223
|
+
{
|
|
224
|
+
...rest,
|
|
225
|
+
focusable: true,
|
|
226
|
+
scrollEventThrottle: 16,
|
|
227
|
+
contentContainerStyle: [
|
|
228
|
+
rest.contentContainerStyle,
|
|
229
|
+
displayRefreshing ? { paddingBottom: holdOffset } : null
|
|
230
|
+
],
|
|
231
|
+
onScroll: (e) => {
|
|
232
|
+
scrollTop.current = e.nativeEvent.contentOffset.y;
|
|
233
|
+
rest.onScroll?.(e);
|
|
234
|
+
},
|
|
235
|
+
onTouchStart: (e) => {
|
|
236
|
+
onTouchStart(e);
|
|
237
|
+
rest.onTouchStart?.(e);
|
|
238
|
+
},
|
|
239
|
+
onTouchMove: (e) => {
|
|
240
|
+
onTouchMove(e);
|
|
241
|
+
rest.onTouchMove?.(e);
|
|
242
|
+
},
|
|
243
|
+
onTouchEnd: (e) => {
|
|
244
|
+
onTouchEnd();
|
|
245
|
+
rest.onTouchEnd?.(e);
|
|
246
|
+
},
|
|
247
|
+
onTouchCancel: (e) => {
|
|
248
|
+
onTouchEnd();
|
|
249
|
+
rest.onTouchCancel?.(e);
|
|
250
|
+
},
|
|
251
|
+
children
|
|
252
|
+
}
|
|
253
|
+
) })
|
|
254
|
+
] });
|
|
255
|
+
}
|
|
256
|
+
var sheet = createStyleSheet((theme) => ({
|
|
257
|
+
root: { flex: 1, overflow: "hidden" },
|
|
258
|
+
content: { flex: 1 },
|
|
259
|
+
// Anchored at the very top of the band; the transform centres it in the gap.
|
|
260
|
+
chrome: {
|
|
261
|
+
position: "absolute",
|
|
262
|
+
top: 0,
|
|
263
|
+
alignSelf: "center",
|
|
264
|
+
zIndex: theme.z.raised,
|
|
265
|
+
alignItems: "center",
|
|
266
|
+
justifyContent: "flex-start",
|
|
267
|
+
// Decorative — the gesture lives on the scroller underneath.
|
|
268
|
+
pointerEvents: "none"
|
|
269
|
+
},
|
|
270
|
+
spinnerBox: {
|
|
271
|
+
alignItems: "center",
|
|
272
|
+
justifyContent: "center"
|
|
273
|
+
},
|
|
274
|
+
// Android: a raised circular puck. iOS keeps the bare inline spinner.
|
|
275
|
+
// Each of the three floaters below is a `surface` shape over live content,
|
|
276
|
+
// held off it by elevation alone — and elevation is zeroed under high
|
|
277
|
+
// contrast. `edge.neutral` is `transparent` at normal contrast and a solid ink
|
|
278
|
+
// there, which is what keeps the puck, the pill and the button legible over
|
|
279
|
+
// whatever the pulled band reveals, at no cost to the resting design.
|
|
280
|
+
spinnerBoxAndroid: {
|
|
281
|
+
borderRadius: theme.radius.full,
|
|
282
|
+
backgroundColor: theme.color.surface,
|
|
283
|
+
borderWidth: theme.borderWidth.base,
|
|
284
|
+
borderColor: theme.edge.neutral,
|
|
285
|
+
...theme.shadow.md
|
|
286
|
+
},
|
|
287
|
+
ring: {
|
|
288
|
+
borderRadius: theme.radius.full,
|
|
289
|
+
borderColor: theme.color.surface3,
|
|
290
|
+
borderTopColor: theme.color.accent
|
|
291
|
+
},
|
|
292
|
+
// The status copy sits on a surface pill so `theme.color.text` clears AA in
|
|
293
|
+
// both modes regardless of what the freed band reveals behind it.
|
|
294
|
+
status: {
|
|
295
|
+
paddingVertical: theme.space.s1,
|
|
296
|
+
paddingHorizontal: theme.space.s3,
|
|
297
|
+
borderRadius: theme.radius.full,
|
|
298
|
+
backgroundColor: theme.color.surface,
|
|
299
|
+
borderWidth: theme.borderWidth.base,
|
|
300
|
+
borderColor: theme.edge.neutral,
|
|
301
|
+
...theme.shadow.sm
|
|
302
|
+
},
|
|
303
|
+
statusHidden: { width: 0, height: 0, overflow: "hidden" },
|
|
304
|
+
statusText: {
|
|
305
|
+
color: theme.color.text,
|
|
306
|
+
fontSize: theme.icon.sm - 3,
|
|
307
|
+
fontWeight: theme.fontWeight.semibold
|
|
308
|
+
},
|
|
309
|
+
refreshButton: {
|
|
310
|
+
position: "absolute",
|
|
311
|
+
top: theme.space.s2,
|
|
312
|
+
end: theme.space.s2,
|
|
313
|
+
zIndex: theme.z.sticky,
|
|
314
|
+
width: theme.tapMin,
|
|
315
|
+
height: theme.tapMin,
|
|
316
|
+
alignItems: "center",
|
|
317
|
+
justifyContent: "center",
|
|
318
|
+
borderRadius: theme.radius.full,
|
|
319
|
+
backgroundColor: theme.color.surface,
|
|
320
|
+
borderWidth: theme.borderWidth.base,
|
|
321
|
+
borderColor: theme.edge.neutral,
|
|
322
|
+
...theme.shadow.sm
|
|
323
|
+
}
|
|
324
|
+
}));
|
|
325
|
+
|
|
326
|
+
export { PullToRefresh };
|