react-native-screen-transitions 3.4.0-alpha.5 → 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 +1058 -11
- 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/hooks/use-backdrop-pointer-events.js.map +1 -1
- package/lib/commonjs/shared/components/screen-container/index.js +12 -8
- package/lib/commonjs/shared/components/screen-container/index.js.map +1 -1
- package/lib/commonjs/shared/components/screen-container/layers/backdrop.js +8 -10
- package/lib/commonjs/shared/components/screen-container/layers/backdrop.js.map +1 -1
- package/lib/commonjs/shared/components/screen-container/layers/content.js +7 -10
- 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 +4 -1
- package/lib/commonjs/shared/constants.js.map +1 -1
- package/lib/commonjs/shared/providers/screen/animation/helpers/hydrate-transition-state.js +33 -1
- package/lib/commonjs/shared/providers/screen/animation/helpers/hydrate-transition-state.js.map +1 -1
- package/lib/commonjs/shared/providers/screen/animation/helpers/pipeline.js +2 -0
- package/lib/commonjs/shared/providers/screen/animation/helpers/pipeline.js.map +1 -1
- package/lib/commonjs/shared/providers/screen/animation/helpers/use-build-transition-state.js +1 -0
- package/lib/commonjs/shared/providers/screen/animation/helpers/use-build-transition-state.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 +57 -31
- 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/hooks/use-backdrop-pointer-events.js.map +1 -1
- package/lib/module/shared/components/screen-container/index.js +12 -8
- package/lib/module/shared/components/screen-container/index.js.map +1 -1
- package/lib/module/shared/components/screen-container/layers/backdrop.js +8 -10
- package/lib/module/shared/components/screen-container/layers/backdrop.js.map +1 -1
- package/lib/module/shared/components/screen-container/layers/content.js +7 -10
- 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 +4 -1
- package/lib/module/shared/constants.js.map +1 -1
- package/lib/module/shared/providers/screen/animation/helpers/hydrate-transition-state.js +32 -1
- package/lib/module/shared/providers/screen/animation/helpers/hydrate-transition-state.js.map +1 -1
- package/lib/module/shared/providers/screen/animation/helpers/pipeline.js +2 -0
- package/lib/module/shared/providers/screen/animation/helpers/pipeline.js.map +1 -1
- package/lib/module/shared/providers/screen/animation/helpers/use-build-transition-state.js +1 -0
- package/lib/module/shared/providers/screen/animation/helpers/use-build-transition-state.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 +56 -29
- 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/hooks/use-backdrop-pointer-events.d.ts +1 -1
- package/lib/typescript/shared/components/screen-container/hooks/use-backdrop-pointer-events.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/backdrop.d.ts +5 -1
- package/lib/typescript/shared/components/screen-container/layers/backdrop.d.ts.map +1 -1
- package/lib/typescript/shared/components/screen-container/layers/content.d.ts +3 -1
- package/lib/typescript/shared/components/screen-container/layers/content.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/animation/helpers/hydrate-transition-state.d.ts +16 -0
- package/lib/typescript/shared/providers/screen/animation/helpers/hydrate-transition-state.d.ts.map +1 -1
- package/lib/typescript/shared/providers/screen/animation/helpers/pipeline.d.ts.map +1 -1
- package/lib/typescript/shared/providers/screen/animation/helpers/use-build-transition-state.d.ts +1 -0
- package/lib/typescript/shared/providers/screen/animation/helpers/use-build-transition-state.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 +16 -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 +4 -5
- 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/hooks/use-backdrop-pointer-events.ts +1 -2
- package/src/shared/components/screen-container/index.tsx +12 -6
- package/src/shared/components/screen-container/layers/backdrop.tsx +13 -7
- package/src/shared/components/screen-container/layers/content.tsx +47 -43
- 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 +3 -0
- package/src/shared/index.ts +0 -1
- package/src/shared/providers/screen/animation/helpers/hydrate-transition-state.ts +49 -1
- package/src/shared/providers/screen/animation/helpers/pipeline.ts +2 -0
- package/src/shared/providers/screen/animation/helpers/use-build-transition-state.ts +2 -0
- 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 +18 -10
- package/src/shared/types/index.ts +0 -1
- package/src/shared/types/screen.types.ts +5 -5
- 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 +94 -59
- package/lib/commonjs/shared/components/screen-container/deferred-visibility-host.js +0 -43
- 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 -38
- 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 -13
- 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 -37
- 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
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
NAVIGATION_MASK_ELEMENT_STYLE_ID,
|
|
7
7
|
NO_STYLES,
|
|
8
8
|
} from "../../../constants";
|
|
9
|
-
import { useScreenStyles } from "../../../providers/screen/styles
|
|
9
|
+
import { useScreenStyles } from "../../../providers/screen/styles";
|
|
10
10
|
import { logger } from "../../../utils/logger";
|
|
11
11
|
|
|
12
12
|
type Props = {
|
|
@@ -27,19 +27,21 @@ let hasWarnedMissingMaskedView = false;
|
|
|
27
27
|
|
|
28
28
|
export const MaybeMaskedNavigationContainer = memo(
|
|
29
29
|
({ enabled, children, pointerEvents }: Props) => {
|
|
30
|
-
const {
|
|
30
|
+
const { layerStylesMap } = useScreenStyles();
|
|
31
31
|
|
|
32
32
|
const animatedNavigationMaskStyle = useAnimatedStyle(() => {
|
|
33
33
|
"worklet";
|
|
34
34
|
return (
|
|
35
|
-
|
|
35
|
+
layerStylesMap.value[NAVIGATION_MASK_ELEMENT_STYLE_ID]?.style ||
|
|
36
|
+
NO_STYLES
|
|
36
37
|
);
|
|
37
38
|
});
|
|
38
39
|
|
|
39
40
|
const animatedNavigationMaskContainerStyle = useAnimatedStyle(() => {
|
|
40
41
|
"worklet";
|
|
41
42
|
return (
|
|
42
|
-
|
|
43
|
+
layerStylesMap.value[NAVIGATION_MASK_CONTAINER_STYLE_ID]?.style ||
|
|
44
|
+
NO_STYLES
|
|
43
45
|
);
|
|
44
46
|
});
|
|
45
47
|
|
|
@@ -6,7 +6,7 @@ import Animated, {
|
|
|
6
6
|
} from "react-native-reanimated";
|
|
7
7
|
import { NO_PROPS, NO_STYLES } from "../../../constants";
|
|
8
8
|
import { useDescriptors } from "../../../providers/screen/descriptors";
|
|
9
|
-
import { useScreenStyles } from "../../../providers/screen/styles
|
|
9
|
+
import { useScreenStyles } from "../../../providers/screen/styles";
|
|
10
10
|
|
|
11
11
|
type Props = {
|
|
12
12
|
children: React.ReactNode;
|
|
@@ -14,7 +14,7 @@ type Props = {
|
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
export const SurfaceContainer = memo(({ children, pointerEvents }: Props) => {
|
|
17
|
-
const {
|
|
17
|
+
const { layerStylesMap } = useScreenStyles();
|
|
18
18
|
const { current } = useDescriptors();
|
|
19
19
|
|
|
20
20
|
const SurfaceComponent = current.options.surfaceComponent;
|
|
@@ -27,12 +27,12 @@ export const SurfaceContainer = memo(({ children, pointerEvents }: Props) => {
|
|
|
27
27
|
|
|
28
28
|
const animatedSurfaceStyle = useAnimatedStyle(() => {
|
|
29
29
|
"worklet";
|
|
30
|
-
return
|
|
30
|
+
return layerStylesMap.value.surface?.style ?? NO_STYLES;
|
|
31
31
|
});
|
|
32
32
|
|
|
33
33
|
const animatedSurfaceProps = useAnimatedProps(() => {
|
|
34
34
|
"worklet";
|
|
35
|
-
return
|
|
35
|
+
return layerStylesMap.value.surface?.props ?? NO_PROPS;
|
|
36
36
|
});
|
|
37
37
|
|
|
38
38
|
if (!AnimatedSurfaceComponent) return children;
|
package/src/shared/constants.ts
CHANGED
|
@@ -57,6 +57,7 @@ export const createScreenTransitionState = (
|
|
|
57
57
|
closing: 0,
|
|
58
58
|
animating: 0,
|
|
59
59
|
settled: 1,
|
|
60
|
+
logicallySettled: 1,
|
|
60
61
|
entering: 0,
|
|
61
62
|
gesture: { ...DEFAULT_GESTURE_VALUES },
|
|
62
63
|
route,
|
|
@@ -79,6 +80,7 @@ export const DEFAULT_SCREEN_TRANSITION_STATE: ScreenTransitionState =
|
|
|
79
80
|
closing: 0,
|
|
80
81
|
animating: 0,
|
|
81
82
|
settled: 1,
|
|
83
|
+
logicallySettled: 1,
|
|
82
84
|
entering: 0,
|
|
83
85
|
gesture: DEFAULT_GESTURE_VALUES,
|
|
84
86
|
route: {} as RouteProp<ParamListBase>,
|
|
@@ -103,6 +105,7 @@ export const EMPTY_BOUND_HELPER_RESULT_RAW = Object.freeze({
|
|
|
103
105
|
translateY: 0,
|
|
104
106
|
width: 0,
|
|
105
107
|
height: 0,
|
|
108
|
+
...HIDDEN_STYLE,
|
|
106
109
|
});
|
|
107
110
|
export const ENTER_RANGE = [0, 1] as const;
|
|
108
111
|
export const EXIT_RANGE = [1, 2] as const;
|
package/src/shared/index.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import type { SharedValue } from "react-native-reanimated";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
ANIMATION_SNAP_THRESHOLD,
|
|
4
|
+
EPSILON,
|
|
5
|
+
FALSE,
|
|
6
|
+
TRUE,
|
|
7
|
+
} from "../../../../constants";
|
|
3
8
|
import type { GestureStoreMap } from "../../../../stores/gesture.store";
|
|
4
9
|
import type { ScreenTransitionState } from "../../../../types/animation.types";
|
|
5
10
|
import type { Layout } from "../../../../types/screen.types";
|
|
@@ -13,6 +18,7 @@ type BuiltState = {
|
|
|
13
18
|
gesture: GestureStoreMap;
|
|
14
19
|
route: BaseStackRoute;
|
|
15
20
|
meta?: Record<string, unknown>;
|
|
21
|
+
targetProgress: SharedValue<number>;
|
|
16
22
|
resolvedAutoSnapPoint: SharedValue<number>;
|
|
17
23
|
measuredContentLayout: SharedValue<Layout | null>;
|
|
18
24
|
hasAutoSnapPoint: boolean;
|
|
@@ -20,6 +26,13 @@ type BuiltState = {
|
|
|
20
26
|
unwrapped: ScreenTransitionState;
|
|
21
27
|
};
|
|
22
28
|
|
|
29
|
+
interface ComputeLogicallySettledParams {
|
|
30
|
+
progress: number;
|
|
31
|
+
targetProgress: number;
|
|
32
|
+
settled: number;
|
|
33
|
+
dragging: number;
|
|
34
|
+
}
|
|
35
|
+
|
|
23
36
|
/**
|
|
24
37
|
* Computes the animated snap index based on progress and snap points.
|
|
25
38
|
* Returns -1 if no snap points, otherwise interpolates between indices.
|
|
@@ -41,6 +54,35 @@ const computeSnapIndex = (progress: number, snapPoints: number[]): number => {
|
|
|
41
54
|
return snapPoints.length - 1;
|
|
42
55
|
};
|
|
43
56
|
|
|
57
|
+
/**
|
|
58
|
+
* Determines whether the screen transition is logically settled.
|
|
59
|
+
*
|
|
60
|
+
* A transition is considered logically settled when:
|
|
61
|
+
* - The `settled` flag is explicitly set, OR
|
|
62
|
+
* - The screen is not being dragged AND the progress is within
|
|
63
|
+
* {@link ANIMATION_SNAP_THRESHOLD} of the target progress.
|
|
64
|
+
*/
|
|
65
|
+
export const computeLogicallySettled = ({
|
|
66
|
+
progress,
|
|
67
|
+
targetProgress,
|
|
68
|
+
settled,
|
|
69
|
+
dragging,
|
|
70
|
+
}: ComputeLogicallySettledParams) => {
|
|
71
|
+
"worklet";
|
|
72
|
+
|
|
73
|
+
if (settled) {
|
|
74
|
+
return TRUE;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (dragging) {
|
|
78
|
+
return FALSE;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return Math.abs(progress - targetProgress) <= ANIMATION_SNAP_THRESHOLD
|
|
82
|
+
? TRUE
|
|
83
|
+
: FALSE;
|
|
84
|
+
};
|
|
85
|
+
|
|
44
86
|
export const hydrateTransitionState = (
|
|
45
87
|
s: BuiltState,
|
|
46
88
|
dimensions: Layout,
|
|
@@ -72,6 +114,12 @@ export const hydrateTransitionState = (
|
|
|
72
114
|
out.gesture.isDragging = out.gesture.dragging;
|
|
73
115
|
|
|
74
116
|
out.settled = out.animating || out.gesture.dismissing || out.closing ? 0 : 1;
|
|
117
|
+
out.logicallySettled = computeLogicallySettled({
|
|
118
|
+
progress: out.progress,
|
|
119
|
+
targetProgress: s.targetProgress.value,
|
|
120
|
+
settled: out.settled,
|
|
121
|
+
dragging: out.gesture.dragging,
|
|
122
|
+
});
|
|
75
123
|
|
|
76
124
|
out.meta = s.meta;
|
|
77
125
|
out.layouts.screen.width = dimensions.width;
|
|
@@ -71,6 +71,7 @@ export function useScreenAnimationPipeline(): ScreenAnimationPipeline {
|
|
|
71
71
|
progress: 0,
|
|
72
72
|
stackProgress: 0,
|
|
73
73
|
snapIndex: -1,
|
|
74
|
+
logicallySettled: 1,
|
|
74
75
|
focused: true,
|
|
75
76
|
active: DEFAULT_SCREEN_TRANSITION_STATE,
|
|
76
77
|
navigationMaskEnabled: currentNavigationMaskEnabled,
|
|
@@ -121,6 +122,7 @@ export function useScreenAnimationPipeline(): ScreenAnimationPipeline {
|
|
|
121
122
|
progress,
|
|
122
123
|
stackProgress,
|
|
123
124
|
snapIndex: current.snapIndex,
|
|
125
|
+
logicallySettled: helpers.active.logicallySettled,
|
|
124
126
|
...helpers,
|
|
125
127
|
};
|
|
126
128
|
|
|
@@ -23,6 +23,7 @@ type BuiltState = {
|
|
|
23
23
|
gesture: GestureStoreMap;
|
|
24
24
|
route: BaseStackRoute;
|
|
25
25
|
meta?: Record<string, unknown>;
|
|
26
|
+
targetProgress: SharedValue<number>;
|
|
26
27
|
resolvedAutoSnapPoint: SharedValue<number>;
|
|
27
28
|
measuredContentLayout: SharedValue<Layout | null>;
|
|
28
29
|
hasAutoSnapPoint: boolean;
|
|
@@ -62,6 +63,7 @@ export const useBuildTransitionState = (
|
|
|
62
63
|
closing: AnimationStore.getValue(key, "closing"),
|
|
63
64
|
entering: AnimationStore.getValue(key, "entering"),
|
|
64
65
|
animating: AnimationStore.getValue(key, "animating"),
|
|
66
|
+
targetProgress: SystemStore.getValue(key, "targetProgress"),
|
|
65
67
|
resolvedAutoSnapPoint: SystemStore.getValue(key, "resolvedAutoSnapPoint"),
|
|
66
68
|
measuredContentLayout: SystemStore.getValue(key, "measuredContentLayout"),
|
|
67
69
|
hasAutoSnapPoint: snapPoints?.includes("auto") ?? false,
|
|
@@ -4,7 +4,7 @@ import { ScreenLifecycle } from "../../components/screen-lifecycle";
|
|
|
4
4
|
import { ScreenGestureProvider } from "../gestures";
|
|
5
5
|
import { ScreenAnimationProvider } from "./animation";
|
|
6
6
|
import { type BaseDescriptor, DescriptorsProvider } from "./descriptors";
|
|
7
|
-
import { ScreenStylesProvider } from "./styles
|
|
7
|
+
import { ScreenStylesProvider } from "./styles";
|
|
8
8
|
|
|
9
9
|
type Props<TDescriptor extends BaseDescriptor> = {
|
|
10
10
|
previous?: TDescriptor;
|
|
@@ -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
|
+
);
|