react-native-screen-transitions 3.4.0-alpha.6 → 3.4.0-alpha.7
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/README.md +136 -46
- package/lib/commonjs/blank-stack/navigators/create-blank-stack-navigator.js +27 -45
- package/lib/commonjs/blank-stack/navigators/create-blank-stack-navigator.js.map +1 -1
- package/lib/commonjs/component-stack/navigators/create-component-stack-navigator.js +1 -1
- package/lib/commonjs/shared/components/create-boundary-component/components/boundary-target.js +39 -0
- package/lib/commonjs/shared/components/create-boundary-component/components/boundary-target.js.map +1 -0
- package/lib/commonjs/shared/components/create-boundary-component/create-boundary-component.js +232 -0
- package/lib/commonjs/shared/components/create-boundary-component/create-boundary-component.js.map +1 -0
- package/lib/commonjs/shared/components/create-boundary-component/hooks/helpers/measurement-rules.js +2 -4
- package/lib/commonjs/shared/components/create-boundary-component/hooks/helpers/measurement-rules.js.map +1 -1
- package/lib/commonjs/shared/components/create-boundary-component/hooks/use-boundary-measure-and-store.js +4 -3
- package/lib/commonjs/shared/components/create-boundary-component/hooks/use-boundary-measure-and-store.js.map +1 -1
- package/lib/commonjs/shared/components/create-boundary-component/hooks/use-pending-destination-retry-measurement.js +2 -1
- package/lib/commonjs/shared/components/create-boundary-component/hooks/use-pending-destination-retry-measurement.js.map +1 -1
- package/lib/commonjs/shared/components/create-boundary-component/index.js +20 -214
- package/lib/commonjs/shared/components/create-boundary-component/index.js.map +1 -1
- package/lib/commonjs/shared/components/create-boundary-component/providers/boundary-owner.provider.js +63 -0
- package/lib/commonjs/shared/components/create-boundary-component/providers/boundary-owner.provider.js.map +1 -0
- package/lib/commonjs/shared/components/create-transition-aware-component.js +29 -7
- package/lib/commonjs/shared/components/create-transition-aware-component.js.map +1 -1
- package/lib/commonjs/shared/components/overlay/variations/float-overlay.js +1 -1
- package/lib/commonjs/shared/components/screen-container/index.js +8 -12
- package/lib/commonjs/shared/components/screen-container/index.js.map +1 -1
- package/lib/commonjs/shared/components/screen-container/layers/backdrop.js +4 -4
- package/lib/commonjs/shared/components/screen-container/layers/backdrop.js.map +1 -1
- package/lib/commonjs/shared/components/screen-container/layers/content.js +4 -4
- package/lib/commonjs/shared/components/screen-container/layers/content.js.map +1 -1
- package/lib/commonjs/shared/components/screen-container/layers/maybe-masked-navigation-container.js +4 -4
- package/lib/commonjs/shared/components/screen-container/layers/maybe-masked-navigation-container.js.map +1 -1
- package/lib/commonjs/shared/components/screen-container/layers/surface-container.js +4 -4
- package/lib/commonjs/shared/components/screen-container/layers/surface-container.js.map +1 -1
- package/lib/commonjs/shared/constants.js +2 -1
- package/lib/commonjs/shared/constants.js.map +1 -1
- package/lib/commonjs/shared/providers/screen/screen-composer.js +1 -1
- package/lib/commonjs/shared/providers/screen/screen-composer.js.map +1 -1
- package/lib/commonjs/shared/providers/screen/styles/helpers/build-resolved-style-map.js +144 -0
- package/lib/commonjs/shared/providers/screen/styles/helpers/build-resolved-style-map.js.map +1 -0
- package/lib/commonjs/shared/providers/screen/styles/helpers/resolve-interpolated-style-output.js +28 -0
- package/lib/commonjs/shared/providers/screen/styles/helpers/resolve-interpolated-style-output.js.map +1 -0
- package/lib/commonjs/shared/providers/screen/styles/helpers/split-normalized-style-maps.js +39 -0
- package/lib/commonjs/shared/providers/screen/styles/helpers/split-normalized-style-maps.js.map +1 -0
- package/lib/commonjs/shared/providers/screen/styles/index.js +25 -0
- package/lib/commonjs/shared/providers/screen/styles/index.js.map +1 -0
- package/lib/commonjs/shared/providers/screen/{styles.provider.js → styles/styles.provider.js} +47 -39
- package/lib/commonjs/shared/providers/screen/styles/styles.provider.js.map +1 -0
- package/lib/commonjs/shared/utils/bounds/helpers/compute-bounds-styles.js +1 -1
- package/lib/commonjs/shared/utils/bounds/helpers/compute-bounds-styles.js.map +1 -1
- package/lib/commonjs/shared/utils/bounds/helpers/style-composers.js +21 -10
- package/lib/commonjs/shared/utils/bounds/helpers/style-composers.js.map +1 -1
- package/lib/commonjs/shared/utils/bounds/zoom/build.js +56 -30
- package/lib/commonjs/shared/utils/bounds/zoom/build.js.map +1 -1
- package/lib/module/blank-stack/navigators/create-blank-stack-navigator.js +27 -45
- package/lib/module/blank-stack/navigators/create-blank-stack-navigator.js.map +1 -1
- package/lib/module/component-stack/navigators/create-component-stack-navigator.js +1 -1
- package/lib/module/shared/components/create-boundary-component/components/boundary-target.js +34 -0
- package/lib/module/shared/components/create-boundary-component/components/boundary-target.js.map +1 -0
- package/lib/module/shared/components/create-boundary-component/create-boundary-component.js +227 -0
- package/lib/module/shared/components/create-boundary-component/create-boundary-component.js.map +1 -0
- package/lib/module/shared/components/create-boundary-component/hooks/helpers/measurement-rules.js +2 -4
- package/lib/module/shared/components/create-boundary-component/hooks/helpers/measurement-rules.js.map +1 -1
- package/lib/module/shared/components/create-boundary-component/hooks/use-boundary-measure-and-store.js +4 -3
- package/lib/module/shared/components/create-boundary-component/hooks/use-boundary-measure-and-store.js.map +1 -1
- package/lib/module/shared/components/create-boundary-component/hooks/use-pending-destination-retry-measurement.js +2 -1
- package/lib/module/shared/components/create-boundary-component/hooks/use-pending-destination-retry-measurement.js.map +1 -1
- package/lib/module/shared/components/create-boundary-component/index.js +16 -213
- package/lib/module/shared/components/create-boundary-component/index.js.map +1 -1
- package/lib/module/shared/components/create-boundary-component/providers/boundary-owner.provider.js +56 -0
- package/lib/module/shared/components/create-boundary-component/providers/boundary-owner.provider.js.map +1 -0
- package/lib/module/shared/components/create-transition-aware-component.js +30 -8
- package/lib/module/shared/components/create-transition-aware-component.js.map +1 -1
- package/lib/module/shared/components/overlay/variations/float-overlay.js +1 -1
- package/lib/module/shared/components/overlay/variations/float-overlay.js.map +1 -1
- package/lib/module/shared/components/screen-container/index.js +8 -12
- package/lib/module/shared/components/screen-container/index.js.map +1 -1
- package/lib/module/shared/components/screen-container/layers/backdrop.js +4 -4
- package/lib/module/shared/components/screen-container/layers/backdrop.js.map +1 -1
- package/lib/module/shared/components/screen-container/layers/content.js +4 -4
- package/lib/module/shared/components/screen-container/layers/content.js.map +1 -1
- package/lib/module/shared/components/screen-container/layers/maybe-masked-navigation-container.js +4 -4
- package/lib/module/shared/components/screen-container/layers/maybe-masked-navigation-container.js.map +1 -1
- package/lib/module/shared/components/screen-container/layers/surface-container.js +4 -4
- package/lib/module/shared/components/screen-container/layers/surface-container.js.map +1 -1
- package/lib/module/shared/constants.js +2 -1
- package/lib/module/shared/constants.js.map +1 -1
- package/lib/module/shared/providers/screen/screen-composer.js +1 -1
- package/lib/module/shared/providers/screen/screen-composer.js.map +1 -1
- package/lib/module/shared/providers/screen/styles/helpers/build-resolved-style-map.js +139 -0
- package/lib/module/shared/providers/screen/styles/helpers/build-resolved-style-map.js.map +1 -0
- package/lib/module/shared/providers/screen/styles/helpers/resolve-interpolated-style-output.js +23 -0
- package/lib/module/shared/providers/screen/styles/helpers/resolve-interpolated-style-output.js.map +1 -0
- package/lib/module/shared/providers/screen/styles/helpers/split-normalized-style-maps.js +34 -0
- package/lib/module/shared/providers/screen/styles/helpers/split-normalized-style-maps.js.map +1 -0
- package/lib/module/shared/providers/screen/styles/index.js +4 -0
- package/lib/module/shared/providers/screen/styles/index.js.map +1 -0
- package/lib/module/shared/providers/screen/{styles.provider.js → styles/styles.provider.js} +48 -40
- package/lib/module/shared/providers/screen/styles/styles.provider.js.map +1 -0
- package/lib/module/shared/utils/bounds/helpers/compute-bounds-styles.js +2 -2
- package/lib/module/shared/utils/bounds/helpers/compute-bounds-styles.js.map +1 -1
- package/lib/module/shared/utils/bounds/helpers/style-composers.js +21 -10
- package/lib/module/shared/utils/bounds/helpers/style-composers.js.map +1 -1
- package/lib/module/shared/utils/bounds/zoom/build.js +55 -28
- package/lib/module/shared/utils/bounds/zoom/build.js.map +1 -1
- package/lib/typescript/blank-stack/navigators/create-blank-stack-navigator.d.ts +9 -15
- package/lib/typescript/blank-stack/navigators/create-blank-stack-navigator.d.ts.map +1 -1
- package/lib/typescript/blank-stack/types.d.ts +6 -4
- package/lib/typescript/blank-stack/types.d.ts.map +1 -1
- package/lib/typescript/component-stack/navigators/create-component-stack-navigator.d.ts +1 -1
- package/lib/typescript/shared/components/create-boundary-component/components/boundary-target.d.ts +209 -0
- package/lib/typescript/shared/components/create-boundary-component/components/boundary-target.d.ts.map +1 -0
- package/lib/typescript/shared/components/create-boundary-component/create-boundary-component.d.ts +8 -0
- package/lib/typescript/shared/components/create-boundary-component/create-boundary-component.d.ts.map +1 -0
- package/lib/typescript/shared/components/create-boundary-component/hooks/helpers/measurement-rules.d.ts.map +1 -1
- package/lib/typescript/shared/components/create-boundary-component/hooks/use-boundary-measure-and-store.d.ts +2 -8
- package/lib/typescript/shared/components/create-boundary-component/hooks/use-boundary-measure-and-store.d.ts.map +1 -1
- package/lib/typescript/shared/components/create-boundary-component/hooks/use-pending-destination-retry-measurement.d.ts +0 -1
- package/lib/typescript/shared/components/create-boundary-component/hooks/use-pending-destination-retry-measurement.d.ts.map +1 -1
- package/lib/typescript/shared/components/create-boundary-component/index.d.ts +216 -12
- package/lib/typescript/shared/components/create-boundary-component/index.d.ts.map +1 -1
- package/lib/typescript/shared/components/create-boundary-component/providers/boundary-owner.provider.d.ts +35 -0
- package/lib/typescript/shared/components/create-boundary-component/providers/boundary-owner.provider.d.ts.map +1 -0
- package/lib/typescript/shared/components/create-transition-aware-component.d.ts.map +1 -1
- package/lib/typescript/shared/components/screen-container/index.d.ts.map +1 -1
- package/lib/typescript/shared/components/screen-container/layers/maybe-masked-navigation-container.d.ts.map +1 -1
- package/lib/typescript/shared/constants.d.ts +1 -0
- package/lib/typescript/shared/constants.d.ts.map +1 -1
- package/lib/typescript/shared/index.d.ts +209 -2
- package/lib/typescript/shared/index.d.ts.map +1 -1
- package/lib/typescript/shared/providers/screen/styles/helpers/build-resolved-style-map.d.ts +11 -0
- package/lib/typescript/shared/providers/screen/styles/helpers/build-resolved-style-map.d.ts.map +1 -0
- package/lib/typescript/shared/providers/screen/styles/helpers/resolve-interpolated-style-output.d.ts +7 -0
- package/lib/typescript/shared/providers/screen/styles/helpers/resolve-interpolated-style-output.d.ts.map +1 -0
- package/lib/typescript/shared/providers/screen/styles/helpers/split-normalized-style-maps.d.ts +6 -0
- package/lib/typescript/shared/providers/screen/styles/helpers/split-normalized-style-maps.d.ts.map +1 -0
- package/lib/typescript/shared/providers/screen/styles/index.d.ts +2 -0
- package/lib/typescript/shared/providers/screen/styles/index.d.ts.map +1 -0
- package/lib/typescript/shared/providers/screen/{styles.provider.d.ts → styles/styles.provider.d.ts} +3 -5
- package/lib/typescript/shared/providers/screen/styles/styles.provider.d.ts.map +1 -0
- package/lib/typescript/shared/types/animation.types.d.ts +3 -9
- package/lib/typescript/shared/types/animation.types.d.ts.map +1 -1
- package/lib/typescript/shared/types/index.d.ts +1 -1
- package/lib/typescript/shared/types/index.d.ts.map +1 -1
- package/lib/typescript/shared/types/screen.types.d.ts +2 -4
- package/lib/typescript/shared/types/screen.types.d.ts.map +1 -1
- package/lib/typescript/shared/utils/bounds/helpers/compute-bounds-styles.d.ts +1 -11
- package/lib/typescript/shared/utils/bounds/helpers/compute-bounds-styles.d.ts.map +1 -1
- package/lib/typescript/shared/utils/bounds/helpers/style-composers.d.ts.map +1 -1
- package/lib/typescript/shared/utils/bounds/zoom/build.d.ts +1 -1
- package/lib/typescript/shared/utils/bounds/zoom/build.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/blank-stack/navigators/create-blank-stack-navigator.tsx +37 -80
- package/src/blank-stack/types.ts +7 -4
- package/src/component-stack/navigators/create-component-stack-navigator.tsx +1 -1
- package/src/shared/components/create-boundary-component/components/boundary-target.tsx +45 -0
- package/src/shared/components/create-boundary-component/create-boundary-component.tsx +282 -0
- package/src/shared/components/create-boundary-component/hooks/helpers/measurement-rules.ts +2 -7
- package/src/shared/components/create-boundary-component/hooks/use-boundary-measure-and-store.ts +6 -10
- package/src/shared/components/create-boundary-component/hooks/use-pending-destination-retry-measurement.ts +3 -2
- package/src/shared/components/create-boundary-component/index.tsx +16 -252
- package/src/shared/components/create-boundary-component/providers/boundary-owner.provider.tsx +109 -0
- package/src/shared/components/create-transition-aware-component.tsx +33 -5
- package/src/shared/components/overlay/variations/float-overlay.tsx +1 -1
- package/src/shared/components/screen-container/index.tsx +10 -13
- package/src/shared/components/screen-container/layers/backdrop.tsx +4 -4
- package/src/shared/components/screen-container/layers/content.tsx +4 -4
- package/src/shared/components/screen-container/layers/maybe-masked-navigation-container.tsx +6 -4
- package/src/shared/components/screen-container/layers/surface-container.tsx +4 -4
- package/src/shared/constants.ts +1 -0
- package/src/shared/index.ts +0 -1
- package/src/shared/providers/screen/screen-composer.tsx +1 -1
- package/src/shared/providers/screen/styles/helpers/build-resolved-style-map.ts +185 -0
- package/src/shared/providers/screen/styles/helpers/resolve-interpolated-style-output.ts +31 -0
- package/src/shared/providers/screen/styles/helpers/split-normalized-style-maps.ts +44 -0
- package/src/shared/providers/screen/styles/index.tsx +5 -0
- package/src/shared/providers/screen/styles/styles.provider.tsx +173 -0
- package/src/shared/types/animation.types.ts +3 -10
- package/src/shared/types/index.ts +0 -1
- package/src/shared/types/screen.types.ts +2 -4
- package/src/shared/utils/bounds/helpers/compute-bounds-styles.ts +2 -1
- package/src/shared/utils/bounds/helpers/style-composers.ts +11 -0
- package/src/shared/utils/bounds/zoom/build.ts +85 -70
- package/lib/commonjs/shared/components/screen-container/deferred-visibility-host.js +0 -45
- package/lib/commonjs/shared/components/screen-container/deferred-visibility-host.js.map +0 -1
- package/lib/commonjs/shared/hooks/animation/use-associated-style.js +0 -234
- package/lib/commonjs/shared/hooks/animation/use-associated-style.js.map +0 -1
- package/lib/commonjs/shared/providers/screen/helpers/resolve-interpolated-style-output.js +0 -50
- package/lib/commonjs/shared/providers/screen/helpers/resolve-interpolated-style-output.js.map +0 -1
- package/lib/commonjs/shared/providers/screen/styles.provider.js.map +0 -1
- package/lib/module/shared/components/screen-container/deferred-visibility-host.js +0 -40
- package/lib/module/shared/components/screen-container/deferred-visibility-host.js.map +0 -1
- package/lib/module/shared/hooks/animation/use-associated-style.js +0 -229
- package/lib/module/shared/hooks/animation/use-associated-style.js.map +0 -1
- package/lib/module/shared/providers/screen/helpers/resolve-interpolated-style-output.js +0 -44
- package/lib/module/shared/providers/screen/helpers/resolve-interpolated-style-output.js.map +0 -1
- package/lib/module/shared/providers/screen/styles.provider.js.map +0 -1
- package/lib/typescript/shared/components/screen-container/deferred-visibility-host.d.ts +0 -14
- package/lib/typescript/shared/components/screen-container/deferred-visibility-host.d.ts.map +0 -1
- package/lib/typescript/shared/hooks/animation/use-associated-style.d.ts +0 -32
- package/lib/typescript/shared/hooks/animation/use-associated-style.d.ts.map +0 -1
- package/lib/typescript/shared/providers/screen/helpers/resolve-interpolated-style-output.d.ts +0 -14
- package/lib/typescript/shared/providers/screen/helpers/resolve-interpolated-style-output.d.ts.map +0 -1
- package/lib/typescript/shared/providers/screen/styles.provider.d.ts.map +0 -1
- package/src/shared/components/screen-container/deferred-visibility-host.tsx +0 -44
- package/src/shared/hooks/animation/use-associated-style.ts +0 -297
- package/src/shared/providers/screen/helpers/resolve-interpolated-style-output.ts +0 -61
- package/src/shared/providers/screen/styles.provider.tsx +0 -164
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { NO_STYLES } from "../../../../constants";
|
|
2
|
+
import type {
|
|
3
|
+
NormalizedTransitionInterpolatedStyle,
|
|
4
|
+
NormalizedTransitionSlotStyle,
|
|
5
|
+
} from "../../../../types/animation.types";
|
|
6
|
+
|
|
7
|
+
export type StyleKeySet = Record<string, true>;
|
|
8
|
+
|
|
9
|
+
type StyleKeyMeta = {
|
|
10
|
+
keys: StyleKeySet;
|
|
11
|
+
hasAny: boolean;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const IDENTITY_TRANSFORM = [
|
|
15
|
+
{ translateX: 0 },
|
|
16
|
+
{ translateY: 0 },
|
|
17
|
+
{ scaleX: 1 },
|
|
18
|
+
{ scaleY: 1 },
|
|
19
|
+
] as const;
|
|
20
|
+
|
|
21
|
+
const ALWAYS_RESET_STYLE_VALUES = {
|
|
22
|
+
zIndex: 0,
|
|
23
|
+
elevation: 0,
|
|
24
|
+
} as const;
|
|
25
|
+
|
|
26
|
+
const hasAnyKeys = (record: Record<string, unknown>) => {
|
|
27
|
+
"worklet";
|
|
28
|
+
for (const _key in record) {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
return false;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const collectStyleKeyMeta = (
|
|
35
|
+
record?: Record<string, unknown>,
|
|
36
|
+
): StyleKeyMeta => {
|
|
37
|
+
"worklet";
|
|
38
|
+
const keys: StyleKeySet = {};
|
|
39
|
+
let hasAny = false;
|
|
40
|
+
|
|
41
|
+
if (!record) {
|
|
42
|
+
return { keys, hasAny };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
for (const key in record) {
|
|
46
|
+
keys[key] = true;
|
|
47
|
+
hasAny = true;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return { keys, hasAny };
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const collectRelevantSlotIds = ({
|
|
54
|
+
currentStylesMap,
|
|
55
|
+
fallbackStylesMap,
|
|
56
|
+
previousStyleKeysBySlot,
|
|
57
|
+
}: {
|
|
58
|
+
currentStylesMap: NormalizedTransitionInterpolatedStyle;
|
|
59
|
+
fallbackStylesMap: NormalizedTransitionInterpolatedStyle;
|
|
60
|
+
previousStyleKeysBySlot: Record<string, StyleKeySet>;
|
|
61
|
+
}) => {
|
|
62
|
+
"worklet";
|
|
63
|
+
const slotIds: Record<string, true> = {};
|
|
64
|
+
|
|
65
|
+
for (const slotId in currentStylesMap) {
|
|
66
|
+
slotIds[slotId] = true;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
for (const slotId in fallbackStylesMap) {
|
|
70
|
+
slotIds[slotId] = true;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
for (const slotId in previousStyleKeysBySlot) {
|
|
74
|
+
slotIds[slotId] = true;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return slotIds;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const buildUnsetPatch = ({
|
|
81
|
+
previousKeys,
|
|
82
|
+
currentKeys,
|
|
83
|
+
}: {
|
|
84
|
+
previousKeys: StyleKeySet;
|
|
85
|
+
currentKeys: StyleKeySet;
|
|
86
|
+
}) => {
|
|
87
|
+
"worklet";
|
|
88
|
+
const unsetPatch: Record<string, any> = {};
|
|
89
|
+
|
|
90
|
+
for (const key in previousKeys) {
|
|
91
|
+
if (currentKeys[key]) continue;
|
|
92
|
+
|
|
93
|
+
if (key === "transform") {
|
|
94
|
+
unsetPatch.transform = IDENTITY_TRANSFORM;
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (key in ALWAYS_RESET_STYLE_VALUES) {
|
|
99
|
+
unsetPatch[key] =
|
|
100
|
+
ALWAYS_RESET_STYLE_VALUES[
|
|
101
|
+
key as keyof typeof ALWAYS_RESET_STYLE_VALUES
|
|
102
|
+
];
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
unsetPatch[key] = undefined;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return unsetPatch;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
export const buildResolvedStyleMap = ({
|
|
113
|
+
currentStylesMap,
|
|
114
|
+
fallbackStylesMap,
|
|
115
|
+
previousStyleKeysBySlot,
|
|
116
|
+
}: {
|
|
117
|
+
currentStylesMap: NormalizedTransitionInterpolatedStyle;
|
|
118
|
+
fallbackStylesMap: NormalizedTransitionInterpolatedStyle;
|
|
119
|
+
previousStyleKeysBySlot: Record<string, StyleKeySet>;
|
|
120
|
+
}): {
|
|
121
|
+
resolvedStylesMap: NormalizedTransitionInterpolatedStyle;
|
|
122
|
+
nextPreviousStyleKeysBySlot: Record<string, StyleKeySet>;
|
|
123
|
+
} => {
|
|
124
|
+
"worklet";
|
|
125
|
+
const resolvedStylesMap: NormalizedTransitionInterpolatedStyle = {};
|
|
126
|
+
const nextPreviousStyleKeysBySlot: Record<string, StyleKeySet> = {};
|
|
127
|
+
|
|
128
|
+
const slotIds = collectRelevantSlotIds({
|
|
129
|
+
currentStylesMap,
|
|
130
|
+
fallbackStylesMap,
|
|
131
|
+
previousStyleKeysBySlot,
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
for (const slotId in slotIds) {
|
|
135
|
+
const slot = currentStylesMap[slotId] ?? fallbackStylesMap[slotId];
|
|
136
|
+
const baseStyle = slot?.style as Record<string, unknown> | undefined;
|
|
137
|
+
const { keys: currentKeys, hasAny: hasCurrentStyleKeys } =
|
|
138
|
+
collectStyleKeyMeta(baseStyle);
|
|
139
|
+
|
|
140
|
+
const unsetPatch = buildUnsetPatch({
|
|
141
|
+
previousKeys: previousStyleKeysBySlot[slotId] ?? {},
|
|
142
|
+
currentKeys,
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
const hasUnsetPatch = hasAnyKeys(unsetPatch);
|
|
146
|
+
const hasProps = slot?.props !== undefined;
|
|
147
|
+
|
|
148
|
+
if (!slot && !hasUnsetPatch) {
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const resolvedStyle =
|
|
153
|
+
hasCurrentStyleKeys || hasUnsetPatch
|
|
154
|
+
? {
|
|
155
|
+
...unsetPatch,
|
|
156
|
+
...(slot?.style ?? NO_STYLES),
|
|
157
|
+
}
|
|
158
|
+
: undefined;
|
|
159
|
+
|
|
160
|
+
if (resolvedStyle === undefined && !hasProps) {
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const resolvedSlot = {} as NormalizedTransitionSlotStyle;
|
|
165
|
+
|
|
166
|
+
if (resolvedStyle !== undefined) {
|
|
167
|
+
resolvedSlot.style = resolvedStyle;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (hasProps) {
|
|
171
|
+
resolvedSlot.props = slot?.props;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
resolvedStylesMap[slotId] = resolvedSlot;
|
|
175
|
+
|
|
176
|
+
if (hasCurrentStyleKeys) {
|
|
177
|
+
nextPreviousStyleKeysBySlot[slotId] = currentKeys;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
return {
|
|
182
|
+
resolvedStylesMap,
|
|
183
|
+
nextPreviousStyleKeysBySlot,
|
|
184
|
+
};
|
|
185
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { NO_STYLES } from "../../../../constants";
|
|
2
|
+
import type {
|
|
3
|
+
NormalizedTransitionInterpolatedStyle,
|
|
4
|
+
TransitionInterpolatedStyle,
|
|
5
|
+
} from "../../../../types/animation.types";
|
|
6
|
+
import { normalizeInterpolatedStyle } from "../../../../utils/normalize-interpolated-style";
|
|
7
|
+
|
|
8
|
+
export type ResolvedInterpolatedStyleOutput = {
|
|
9
|
+
stylesMap: NormalizedTransitionInterpolatedStyle;
|
|
10
|
+
wasLegacy: boolean;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const resolveInterpolatedStyleOutput = (
|
|
14
|
+
raw: TransitionInterpolatedStyle | null | undefined,
|
|
15
|
+
): ResolvedInterpolatedStyleOutput => {
|
|
16
|
+
"worklet";
|
|
17
|
+
|
|
18
|
+
if (raw == null || typeof raw !== "object") {
|
|
19
|
+
return {
|
|
20
|
+
stylesMap: NO_STYLES,
|
|
21
|
+
wasLegacy: false,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const { result, wasLegacy } = normalizeInterpolatedStyle(raw);
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
stylesMap: result,
|
|
29
|
+
wasLegacy,
|
|
30
|
+
};
|
|
31
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import {
|
|
2
|
+
NAVIGATION_MASK_CONTAINER_STYLE_ID,
|
|
3
|
+
NAVIGATION_MASK_ELEMENT_STYLE_ID,
|
|
4
|
+
} from "../../../../constants";
|
|
5
|
+
import type { NormalizedTransitionInterpolatedStyle } from "../../../../types/animation.types";
|
|
6
|
+
|
|
7
|
+
const LAYER_STYLE_SLOT_IDS = {
|
|
8
|
+
content: true,
|
|
9
|
+
backdrop: true,
|
|
10
|
+
surface: true,
|
|
11
|
+
[NAVIGATION_MASK_ELEMENT_STYLE_ID]: true,
|
|
12
|
+
[NAVIGATION_MASK_CONTAINER_STYLE_ID]: true,
|
|
13
|
+
} as const;
|
|
14
|
+
|
|
15
|
+
const isLayerStyleSlotId = (slotId: string) => {
|
|
16
|
+
"worklet";
|
|
17
|
+
// biome-ignore lint/suspicious/noPrototypeBuiltins: <Typescript lib target is ES2020>
|
|
18
|
+
return Object.prototype.hasOwnProperty.call(LAYER_STYLE_SLOT_IDS, slotId);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const splitNormalizedStyleMaps = (
|
|
22
|
+
stylesMap: NormalizedTransitionInterpolatedStyle,
|
|
23
|
+
): {
|
|
24
|
+
layerStylesMap: NormalizedTransitionInterpolatedStyle;
|
|
25
|
+
elementStylesMap: NormalizedTransitionInterpolatedStyle;
|
|
26
|
+
} => {
|
|
27
|
+
"worklet";
|
|
28
|
+
const layerStylesMap: NormalizedTransitionInterpolatedStyle = {};
|
|
29
|
+
const elementStylesMap: NormalizedTransitionInterpolatedStyle = {};
|
|
30
|
+
|
|
31
|
+
for (const slotId in stylesMap) {
|
|
32
|
+
if (isLayerStyleSlotId(slotId)) {
|
|
33
|
+
layerStylesMap[slotId] = stylesMap[slotId];
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
elementStylesMap[slotId] = stylesMap[slotId];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return {
|
|
41
|
+
layerStylesMap,
|
|
42
|
+
elementStylesMap,
|
|
43
|
+
};
|
|
44
|
+
};
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { type ReactNode, useContext, useMemo } from "react";
|
|
2
|
+
import {
|
|
3
|
+
type SharedValue,
|
|
4
|
+
useDerivedValue,
|
|
5
|
+
useSharedValue,
|
|
6
|
+
} from "react-native-reanimated";
|
|
7
|
+
import { NO_STYLES } from "../../../constants";
|
|
8
|
+
import type { NormalizedTransitionInterpolatedStyle } from "../../../types/animation.types";
|
|
9
|
+
import createProvider from "../../../utils/create-provider";
|
|
10
|
+
import { logger } from "../../../utils/logger";
|
|
11
|
+
import { useScreenAnimationContext } from "../animation";
|
|
12
|
+
import {
|
|
13
|
+
buildResolvedStyleMap,
|
|
14
|
+
type StyleKeySet,
|
|
15
|
+
} from "./helpers/build-resolved-style-map";
|
|
16
|
+
import { resolveInterpolatedStyleOutput } from "./helpers/resolve-interpolated-style-output";
|
|
17
|
+
import { splitNormalizedStyleMaps } from "./helpers/split-normalized-style-maps";
|
|
18
|
+
|
|
19
|
+
type Props = {
|
|
20
|
+
children: ReactNode;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
type ScreenStylesContextValue = {
|
|
24
|
+
layerStylesMap: SharedValue<NormalizedTransitionInterpolatedStyle>;
|
|
25
|
+
elementStylesMap: SharedValue<NormalizedTransitionInterpolatedStyle>;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const {
|
|
29
|
+
ScreenStylesProvider,
|
|
30
|
+
ScreenStylesContext,
|
|
31
|
+
useScreenStylesContext: useScreenStyles,
|
|
32
|
+
} = createProvider("ScreenStyles", {
|
|
33
|
+
guarded: true,
|
|
34
|
+
})<Props, ScreenStylesContextValue>(
|
|
35
|
+
({ children }): { value: ScreenStylesContextValue; children: ReactNode } => {
|
|
36
|
+
const parentContext = useContext(ScreenStylesContext);
|
|
37
|
+
|
|
38
|
+
const {
|
|
39
|
+
screenInterpolatorProps,
|
|
40
|
+
nextInterpolator,
|
|
41
|
+
currentInterpolator,
|
|
42
|
+
boundsAccessor,
|
|
43
|
+
} = useScreenAnimationContext();
|
|
44
|
+
|
|
45
|
+
const isGesturingDuringCloseAnimation = useSharedValue(false);
|
|
46
|
+
const hasWarnedLegacy = useSharedValue(false);
|
|
47
|
+
const previousLayerStyleKeysBySlot = useSharedValue<
|
|
48
|
+
Record<string, StyleKeySet>
|
|
49
|
+
>({});
|
|
50
|
+
const previousElementStyleKeysBySlot = useSharedValue<
|
|
51
|
+
Record<string, StyleKeySet>
|
|
52
|
+
>({});
|
|
53
|
+
|
|
54
|
+
const rawStyleResolution = useDerivedValue<{
|
|
55
|
+
layerStylesMap: NormalizedTransitionInterpolatedStyle;
|
|
56
|
+
elementStylesMap: NormalizedTransitionInterpolatedStyle;
|
|
57
|
+
}>(() => {
|
|
58
|
+
"worklet";
|
|
59
|
+
const props = screenInterpolatorProps.value;
|
|
60
|
+
const { current, next, progress } = props;
|
|
61
|
+
const isDragging = current.gesture.dragging;
|
|
62
|
+
const isNextClosing = !!next?.closing;
|
|
63
|
+
|
|
64
|
+
if (isDragging && isNextClosing) {
|
|
65
|
+
isGesturingDuringCloseAnimation.value = true;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (!isDragging && !isNextClosing) {
|
|
69
|
+
isGesturingDuringCloseAnimation.value = false;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const isInGestureMode =
|
|
73
|
+
isDragging || isGesturingDuringCloseAnimation.value;
|
|
74
|
+
|
|
75
|
+
const interpolator = isInGestureMode
|
|
76
|
+
? currentInterpolator
|
|
77
|
+
: (nextInterpolator ?? currentInterpolator);
|
|
78
|
+
|
|
79
|
+
if (!interpolator) {
|
|
80
|
+
return {
|
|
81
|
+
layerStylesMap: NO_STYLES,
|
|
82
|
+
elementStylesMap: NO_STYLES,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
let effectiveProgress = progress;
|
|
87
|
+
let effectiveNext = next;
|
|
88
|
+
|
|
89
|
+
if (isInGestureMode) {
|
|
90
|
+
effectiveProgress = current.progress;
|
|
91
|
+
effectiveNext = undefined;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
try {
|
|
95
|
+
const raw = interpolator({
|
|
96
|
+
...props,
|
|
97
|
+
progress: effectiveProgress,
|
|
98
|
+
next: effectiveNext,
|
|
99
|
+
bounds: boundsAccessor,
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
const { stylesMap, wasLegacy } = resolveInterpolatedStyleOutput(raw);
|
|
103
|
+
|
|
104
|
+
const { layerStylesMap, elementStylesMap } =
|
|
105
|
+
splitNormalizedStyleMaps(stylesMap);
|
|
106
|
+
|
|
107
|
+
if (__DEV__ && wasLegacy && !hasWarnedLegacy.value) {
|
|
108
|
+
hasWarnedLegacy.value = true;
|
|
109
|
+
logger.warn(
|
|
110
|
+
"Flat interpolator return shape (contentStyle/backdropStyle) is deprecated. " +
|
|
111
|
+
"Use the nested format instead: { content: { style }, backdrop: { style } }.",
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return {
|
|
116
|
+
layerStylesMap,
|
|
117
|
+
elementStylesMap,
|
|
118
|
+
};
|
|
119
|
+
} catch (err) {
|
|
120
|
+
if (__DEV__) {
|
|
121
|
+
console.warn(
|
|
122
|
+
"[react-native-screen-transitions] screenStyleInterpolator must be a worklet",
|
|
123
|
+
err,
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return {
|
|
128
|
+
layerStylesMap: NO_STYLES,
|
|
129
|
+
elementStylesMap: NO_STYLES,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
const layerStylesMap =
|
|
135
|
+
useDerivedValue<NormalizedTransitionInterpolatedStyle>(() => {
|
|
136
|
+
"worklet";
|
|
137
|
+
const { resolvedStylesMap, nextPreviousStyleKeysBySlot } =
|
|
138
|
+
buildResolvedStyleMap({
|
|
139
|
+
currentStylesMap: rawStyleResolution.value.layerStylesMap,
|
|
140
|
+
fallbackStylesMap: NO_STYLES,
|
|
141
|
+
previousStyleKeysBySlot: previousLayerStyleKeysBySlot.value,
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
previousLayerStyleKeysBySlot.value = nextPreviousStyleKeysBySlot;
|
|
145
|
+
return resolvedStylesMap;
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
const elementStylesMap =
|
|
149
|
+
useDerivedValue<NormalizedTransitionInterpolatedStyle>(() => {
|
|
150
|
+
"worklet";
|
|
151
|
+
const { resolvedStylesMap, nextPreviousStyleKeysBySlot } =
|
|
152
|
+
buildResolvedStyleMap({
|
|
153
|
+
currentStylesMap: rawStyleResolution.value.elementStylesMap,
|
|
154
|
+
fallbackStylesMap:
|
|
155
|
+
parentContext?.elementStylesMap.value ?? NO_STYLES,
|
|
156
|
+
previousStyleKeysBySlot: previousElementStyleKeysBySlot.value,
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
previousElementStyleKeysBySlot.value = nextPreviousStyleKeysBySlot;
|
|
160
|
+
|
|
161
|
+
return resolvedStylesMap;
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
const value = useMemo<ScreenStylesContextValue>(() => {
|
|
165
|
+
return {
|
|
166
|
+
layerStylesMap,
|
|
167
|
+
elementStylesMap,
|
|
168
|
+
};
|
|
169
|
+
}, [elementStylesMap, layerStylesMap]);
|
|
170
|
+
|
|
171
|
+
return { value, children };
|
|
172
|
+
},
|
|
173
|
+
);
|
|
@@ -209,19 +209,12 @@ export interface ScreenInterpolationProps {
|
|
|
209
209
|
}
|
|
210
210
|
|
|
211
211
|
/**
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
*/
|
|
215
|
-
export type DeferredScreenStyleSignal = "defer";
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* Returning `'defer'` explicitly hides the screen's visual subtree until the
|
|
219
|
-
* transition is ready. Returning `null`, `undefined`, or `{}` applies no
|
|
220
|
-
* transition styles for the current frame.
|
|
212
|
+
* Returning `null`, `undefined`, or `{}` applies no transition styles for the
|
|
213
|
+
* current frame.
|
|
221
214
|
*/
|
|
222
215
|
export type ScreenStyleInterpolator = (
|
|
223
216
|
props: ScreenInterpolationProps,
|
|
224
|
-
) => TransitionInterpolatedStyle |
|
|
217
|
+
) => TransitionInterpolatedStyle | null | undefined;
|
|
225
218
|
|
|
226
219
|
/**
|
|
227
220
|
* Animated style properties with full autocomplete.
|
|
@@ -83,10 +83,8 @@ export type ScreenTransitionConfig = {
|
|
|
83
83
|
/**
|
|
84
84
|
* The user-provided function to calculate styles based on animation progress.
|
|
85
85
|
*
|
|
86
|
-
* Return `null`
|
|
87
|
-
*
|
|
88
|
-
* `bounds().navigation.zoom()` where the screen should stay hidden until the
|
|
89
|
-
* interpolator has enough state to produce a safe first frame.
|
|
86
|
+
* Return `null`, `undefined`, or `{}` to apply no transition styles for the
|
|
87
|
+
* current frame.
|
|
90
88
|
*/
|
|
91
89
|
screenStyleInterpolator?: ScreenStyleInterpolator;
|
|
92
90
|
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
EXIT_RANGE,
|
|
6
6
|
FULLSCREEN_DIMENSIONS,
|
|
7
7
|
HIDDEN_STYLE,
|
|
8
|
+
NO_STYLES,
|
|
8
9
|
} from "../../../constants";
|
|
9
10
|
import {
|
|
10
11
|
BoundStore,
|
|
@@ -127,7 +128,7 @@ export const computeBoundStyles = (
|
|
|
127
128
|
if (computeOptions.raw) {
|
|
128
129
|
return EMPTY_BOUND_HELPER_RESULT_RAW;
|
|
129
130
|
}
|
|
130
|
-
return
|
|
131
|
+
return NO_STYLES;
|
|
131
132
|
}
|
|
132
133
|
|
|
133
134
|
const {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { MeasuredDimensions, StyleProps } from "react-native-reanimated";
|
|
2
|
+
import { VISIBLE_STYLE } from "../../../constants";
|
|
2
3
|
import type {
|
|
3
4
|
ContentTransformGeometry,
|
|
4
5
|
RelativeGeometry,
|
|
@@ -132,6 +133,7 @@ export function composeSizeAbsolute(params: ElementComposeParams): StyleProps {
|
|
|
132
133
|
height,
|
|
133
134
|
translateX,
|
|
134
135
|
translateY,
|
|
136
|
+
...VISIBLE_STYLE,
|
|
135
137
|
};
|
|
136
138
|
}
|
|
137
139
|
|
|
@@ -139,6 +141,7 @@ export function composeSizeAbsolute(params: ElementComposeParams): StyleProps {
|
|
|
139
141
|
width,
|
|
140
142
|
height,
|
|
141
143
|
transform: [{ translateX }, { translateY }],
|
|
144
|
+
...VISIBLE_STYLE,
|
|
142
145
|
};
|
|
143
146
|
}
|
|
144
147
|
|
|
@@ -175,6 +178,7 @@ export function composeSizeRelative(params: ElementComposeParams): StyleProps {
|
|
|
175
178
|
translateY,
|
|
176
179
|
width,
|
|
177
180
|
height,
|
|
181
|
+
...VISIBLE_STYLE,
|
|
178
182
|
};
|
|
179
183
|
}
|
|
180
184
|
|
|
@@ -182,6 +186,7 @@ export function composeSizeRelative(params: ElementComposeParams): StyleProps {
|
|
|
182
186
|
transform: [{ translateX }, { translateY }],
|
|
183
187
|
width,
|
|
184
188
|
height,
|
|
189
|
+
...VISIBLE_STYLE,
|
|
185
190
|
};
|
|
186
191
|
}
|
|
187
192
|
|
|
@@ -210,11 +215,13 @@ export function composeTransformAbsolute(
|
|
|
210
215
|
translateY,
|
|
211
216
|
scaleX,
|
|
212
217
|
scaleY,
|
|
218
|
+
...VISIBLE_STYLE,
|
|
213
219
|
};
|
|
214
220
|
}
|
|
215
221
|
|
|
216
222
|
return {
|
|
217
223
|
transform: [{ translateX }, { translateY }, { scaleX }, { scaleY }],
|
|
224
|
+
...VISIBLE_STYLE,
|
|
218
225
|
};
|
|
219
226
|
}
|
|
220
227
|
|
|
@@ -243,6 +250,7 @@ export function composeTransformRelative(
|
|
|
243
250
|
translateY,
|
|
244
251
|
scaleX,
|
|
245
252
|
scaleY,
|
|
253
|
+
...VISIBLE_STYLE,
|
|
246
254
|
};
|
|
247
255
|
}
|
|
248
256
|
|
|
@@ -255,6 +263,7 @@ export function composeTransformRelative(
|
|
|
255
263
|
{ scaleX },
|
|
256
264
|
{ scaleY },
|
|
257
265
|
],
|
|
266
|
+
...VISIBLE_STYLE,
|
|
258
267
|
};
|
|
259
268
|
}
|
|
260
269
|
|
|
@@ -283,10 +292,12 @@ export function composeContentStyle(params: ContentComposeParams): StyleProps {
|
|
|
283
292
|
translateX,
|
|
284
293
|
translateY,
|
|
285
294
|
scale,
|
|
295
|
+
...VISIBLE_STYLE,
|
|
286
296
|
};
|
|
287
297
|
}
|
|
288
298
|
|
|
289
299
|
return {
|
|
290
300
|
transform: [{ translateX }, { translateY }, { scale }],
|
|
301
|
+
...VISIBLE_STYLE,
|
|
291
302
|
};
|
|
292
303
|
}
|