@symbiote-native/vue 0.3.7 → 0.4.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/build/components/flat-list/index.js +18 -34
- package/build/components/image-background.js +4 -14
- package/build/components/image.js +9 -20
- package/build/components/keyboard-avoiding-view.js +10 -19
- package/build/components/modal/index.d.ts +4 -4
- package/build/components/pressable.js +24 -31
- package/build/components/refresh-control.js +12 -18
- package/build/components/scroll-view/index.android.js +21 -33
- package/build/components/scroll-view/shared.js +76 -121
- package/build/components/scroll-view/sticky-header.js +104 -104
- package/build/components/section-list/index.js +12 -19
- package/build/components/switch/shared.js +17 -29
- package/build/components/text-input/index.js +29 -49
- package/build/components/touchable.js +30 -50
- package/build/components/virtualized-list/index.js +174 -273
- package/build/components/virtualized-section-list/index.js +19 -29
- package/build/components.js +1 -3
- package/build/host-instance/index.js +2 -4
- package/build/index.d.ts +2 -1
- package/build/index.js +11 -45
- package/build/modules/animated/create-animated-component.js +34 -97
- package/build/modules/animated/index.js +13 -17
- package/build/modules/app-registry/index.js +7 -11
- package/build/modules/status-bar.js +8 -15
- package/build/renderer/index.js +11 -6
- package/build/runtime-helpers/index.js +16 -26
- package/metro-css-parser.cjs +9 -14
- package/metro-vue-transformer.cjs +112 -135
- package/package.json +4 -4
|
@@ -11,14 +11,20 @@
|
|
|
11
11
|
// Inputs arrive as attrs (untyped), narrowed with runtime guards. The handlers read attrs LIVE
|
|
12
12
|
// (they fire on events, not render) so a re-supplied callback / timing is always honored.
|
|
13
13
|
import { defineComponent, h } from '@vue/runtime-core';
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
14
|
+
import { createTouchableFeedbackHandlers, createTouchableFeedbackRuntime, highlightPressedStyle, DEFAULT_ACTIVE_OPACITY, DEFAULT_HIGHLIGHT_CHILD_OPACITY, DEFAULT_MIN_PRESS_DURATION_MS, DEFAULT_UNDERLAY_COLOR, OPACITY_ACTIVE_DURATION_MS, OPACITY_INACTIVE_DURATION_MS, RESTING_OPACITY, } from '@symbiote-native/components';
|
|
15
|
+
import {} from '@symbiote-native/engine';
|
|
16
16
|
import { Pressable, emitPressableEvents, PRESSABLE_EMITS, } from './pressable.js';
|
|
17
17
|
import { Animated } from '../modules/animated/index.js';
|
|
18
18
|
import { normalizeVueAttrs } from '../utils/normalize-attrs.js';
|
|
19
19
|
function numberOr(value, fallback) {
|
|
20
20
|
return typeof value === 'number' ? value : fallback;
|
|
21
21
|
}
|
|
22
|
+
// The real setTimeout the shared feedback machine schedules its deferred activation/deactivation on
|
|
23
|
+
// (core/components has no timer globals). Returns a canceller so an early release flushes the timer.
|
|
24
|
+
function scheduleTimeout(callback, ms) {
|
|
25
|
+
const id = setTimeout(callback, ms);
|
|
26
|
+
return () => clearTimeout(id);
|
|
27
|
+
}
|
|
22
28
|
function forwardExcept(attrs, handled) {
|
|
23
29
|
const result = {};
|
|
24
30
|
for (const key of Object.keys(attrs)) {
|
|
@@ -41,8 +47,9 @@ export const TouchableOpacity = defineComponent((_props, { slots, attrs: rawAttr
|
|
|
41
47
|
// One Animated.Value per mount, resting at full opacity. Held by identity in setup scope (an
|
|
42
48
|
// engine object, never a reactive ref). The Animated.View leaf commits it every frame.
|
|
43
49
|
const opacity = new Animated.Value(RESTING_OPACITY);
|
|
44
|
-
|
|
45
|
-
|
|
50
|
+
// The shared press-scheduling cell (delayPressIn timer + activation clock), persisted across
|
|
51
|
+
// renders in setup scope; the handlers are rebuilt each render over live attrs.
|
|
52
|
+
const runtime = createTouchableFeedbackRuntime();
|
|
46
53
|
function setOpacityTo(toValue, duration) {
|
|
47
54
|
Animated.timing(opacity, {
|
|
48
55
|
toValue,
|
|
@@ -51,51 +58,27 @@ export const TouchableOpacity = defineComponent((_props, { slots, attrs: rawAttr
|
|
|
51
58
|
useNativeDriver: false,
|
|
52
59
|
}).start();
|
|
53
60
|
}
|
|
54
|
-
function clearPressInTimer() {
|
|
55
|
-
if (pressInTimer !== undefined) {
|
|
56
|
-
clearTimeout(pressInTimer);
|
|
57
|
-
pressInTimer = undefined;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
function activate(event) {
|
|
61
|
-
activatedAt = Date.now();
|
|
62
|
-
setOpacityTo(numberOr(rawAttrs.activeOpacity, DEFAULT_ACTIVE_OPACITY), OPACITY_ACTIVE_DURATION_MS);
|
|
63
|
-
emit('pressIn', event);
|
|
64
|
-
}
|
|
65
|
-
function deactivate(event) {
|
|
66
|
-
activatedAt = undefined;
|
|
67
|
-
setOpacityTo(RESTING_OPACITY, OPACITY_INACTIVE_DURATION_MS);
|
|
68
|
-
emit('pressOut', event);
|
|
69
|
-
}
|
|
70
|
-
function handlePressIn(event) {
|
|
71
|
-
const delayPressIn = numberOr(rawAttrs.delayPressIn, 0);
|
|
72
|
-
if (delayPressIn > 0) {
|
|
73
|
-
dlog(`TouchableOpacity pressIn deferred ${delayPressIn}ms`);
|
|
74
|
-
pressInTimer = setTimeout(() => {
|
|
75
|
-
pressInTimer = undefined;
|
|
76
|
-
activate(event);
|
|
77
|
-
}, delayPressIn);
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
activate(event);
|
|
81
|
-
}
|
|
82
|
-
function handlePressOut(event) {
|
|
83
|
-
if (pressInTimer !== undefined) {
|
|
84
|
-
clearPressInTimer();
|
|
85
|
-
activate(event);
|
|
86
|
-
}
|
|
87
|
-
const heldFor = activatedAt === undefined ? 0 : Date.now() - activatedAt;
|
|
88
|
-
const wait = computePressOutWait(heldFor, numberOr(rawAttrs.minPressDuration, DEFAULT_MIN_PRESS_DURATION_MS), numberOr(rawAttrs.delayPressOut, 0));
|
|
89
|
-
if (wait > 0) {
|
|
90
|
-
dlog(`TouchableOpacity pressOut deferred ${wait}ms`);
|
|
91
|
-
setTimeout(() => deactivate(event), wait);
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
deactivate(event);
|
|
95
|
-
}
|
|
96
61
|
return () => {
|
|
97
62
|
const attrs = normalizeVueAttrs(rawAttrs);
|
|
98
63
|
const style = attrs.style;
|
|
64
|
+
// Rebuilt each render so a re-supplied delay/opacity is honored (Vue's live-attr idiom); the
|
|
65
|
+
// shared machine owns the scheduling, the adapter supplies the Animated fade + emit.
|
|
66
|
+
const { handlePressIn, handlePressOut } = createTouchableFeedbackHandlers({
|
|
67
|
+
delayPressIn: numberOr(attrs.delayPressIn, 0),
|
|
68
|
+
delayPressOut: numberOr(attrs.delayPressOut, 0),
|
|
69
|
+
minPressDuration: numberOr(attrs.minPressDuration, DEFAULT_MIN_PRESS_DURATION_MS),
|
|
70
|
+
schedule: scheduleTimeout,
|
|
71
|
+
now: Date.now,
|
|
72
|
+
}, runtime, {
|
|
73
|
+
activate(event) {
|
|
74
|
+
setOpacityTo(numberOr(attrs.activeOpacity, DEFAULT_ACTIVE_OPACITY), OPACITY_ACTIVE_DURATION_MS);
|
|
75
|
+
emit('pressIn', event);
|
|
76
|
+
},
|
|
77
|
+
deactivate(event) {
|
|
78
|
+
setOpacityTo(RESTING_OPACITY, OPACITY_INACTIVE_DURATION_MS);
|
|
79
|
+
emit('pressOut', event);
|
|
80
|
+
},
|
|
81
|
+
});
|
|
99
82
|
const pressableProps = {
|
|
100
83
|
...forwardExcept(attrs, TOUCHABLE_OPACITY_HANDLED),
|
|
101
84
|
...emitPressableEvents(emit),
|
|
@@ -119,10 +102,7 @@ export const TouchableHighlight = defineComponent((_props, { slots, attrs: rawAt
|
|
|
119
102
|
const underlayColor = typeof attrs.underlayColor === 'string' ? attrs.underlayColor : DEFAULT_UNDERLAY_COLOR;
|
|
120
103
|
const style = attrs.style;
|
|
121
104
|
function pressedStyle({ pressed }) {
|
|
122
|
-
|
|
123
|
-
return style;
|
|
124
|
-
const overlay = { backgroundColor: underlayColor, opacity: activeOpacity };
|
|
125
|
-
return [style, overlay];
|
|
105
|
+
return highlightPressedStyle(pressed, style, underlayColor, activeOpacity);
|
|
126
106
|
}
|
|
127
107
|
const pressableProps = {
|
|
128
108
|
...forwardExcept(attrs, TOUCHABLE_HIGHLIGHT_HANDLED),
|