react-native-screen-transitions 3.2.0-beta.2 → 3.2.0-beta.3
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 +108 -37
- package/lib/commonjs/blank-stack/components/stack-view.js +0 -2
- package/lib/commonjs/blank-stack/components/stack-view.js.map +1 -1
- package/lib/commonjs/blank-stack/components/stack-view.native.js +0 -2
- package/lib/commonjs/blank-stack/components/stack-view.native.js.map +1 -1
- package/lib/commonjs/component-stack/components/stack-view.js +16 -20
- package/lib/commonjs/component-stack/components/stack-view.js.map +1 -1
- package/lib/commonjs/native-stack/views/NativeStackView.native.js +3 -3
- package/lib/commonjs/native-stack/views/NativeStackView.native.js.map +1 -1
- package/lib/commonjs/shared/components/overlay/variations/float-overlay.js +1 -6
- package/lib/commonjs/shared/components/overlay/variations/float-overlay.js.map +1 -1
- package/lib/commonjs/shared/components/overlay/variations/overlay-host.js +16 -64
- package/lib/commonjs/shared/components/overlay/variations/overlay-host.js.map +1 -1
- package/lib/commonjs/shared/components/overlay/variations/screen-overlay.js +5 -8
- package/lib/commonjs/shared/components/overlay/variations/screen-overlay.js.map +1 -1
- package/lib/commonjs/shared/components/screen-lifecycle.js +153 -0
- package/lib/commonjs/shared/components/screen-lifecycle.js.map +1 -0
- package/lib/commonjs/shared/constants.js +3 -2
- package/lib/commonjs/shared/constants.js.map +1 -1
- package/lib/commonjs/shared/hooks/animation/use-screen-animation.js.map +1 -1
- package/lib/commonjs/shared/hooks/gestures/use-build-gestures.js.map +1 -1
- package/lib/commonjs/shared/hooks/navigation/use-screen-state.js +45 -0
- package/lib/commonjs/shared/hooks/navigation/use-screen-state.js.map +1 -0
- package/lib/commonjs/shared/hooks/use-stable-callback-value.js +0 -2
- package/lib/commonjs/shared/hooks/use-stable-callback-value.js.map +1 -1
- package/lib/commonjs/shared/index.js +7 -0
- package/lib/commonjs/shared/index.js.map +1 -1
- package/lib/commonjs/shared/providers/screen/keys.provider.js +0 -2
- package/lib/commonjs/shared/providers/screen/keys.provider.js.map +1 -1
- package/lib/commonjs/shared/providers/screen/screen-composer.js +3 -3
- package/lib/commonjs/shared/providers/screen/screen-composer.js.map +1 -1
- package/lib/commonjs/shared/providers/screen/styles.provider.js +1 -1
- package/lib/commonjs/shared/providers/screen/styles.provider.js.map +1 -1
- package/lib/commonjs/shared/types/index.js +3 -3
- package/lib/commonjs/shared/types/index.js.map +1 -1
- package/lib/commonjs/shared/types/stack.types.js +4 -0
- package/lib/commonjs/shared/types/stack.types.js.map +1 -1
- package/lib/commonjs/shared/utils/animation/start-screen-transition.js +5 -5
- package/lib/commonjs/shared/utils/animation/start-screen-transition.js.map +1 -1
- package/lib/commonjs/shared/utils/bounds/index.js.map +1 -1
- package/lib/module/blank-stack/components/stack-view.js +0 -2
- package/lib/module/blank-stack/components/stack-view.js.map +1 -1
- package/lib/module/blank-stack/components/stack-view.native.js +0 -2
- package/lib/module/blank-stack/components/stack-view.native.js.map +1 -1
- package/lib/module/component-stack/components/stack-view.js +16 -20
- package/lib/module/component-stack/components/stack-view.js.map +1 -1
- package/lib/module/native-stack/views/NativeStackView.native.js +3 -3
- package/lib/module/native-stack/views/NativeStackView.native.js.map +1 -1
- package/lib/module/shared/components/overlay/variations/float-overlay.js +1 -6
- package/lib/module/shared/components/overlay/variations/float-overlay.js.map +1 -1
- package/lib/module/shared/components/overlay/variations/overlay-host.js +16 -64
- package/lib/module/shared/components/overlay/variations/overlay-host.js.map +1 -1
- package/lib/module/shared/components/overlay/variations/screen-overlay.js +5 -8
- package/lib/module/shared/components/overlay/variations/screen-overlay.js.map +1 -1
- package/lib/module/shared/components/screen-lifecycle.js +147 -0
- package/lib/module/shared/components/screen-lifecycle.js.map +1 -0
- package/lib/module/shared/constants.js +2 -1
- package/lib/module/shared/constants.js.map +1 -1
- package/lib/module/shared/hooks/animation/use-screen-animation.js.map +1 -1
- package/lib/module/shared/hooks/gestures/use-build-gestures.js.map +1 -1
- package/lib/module/shared/hooks/navigation/use-screen-state.js +41 -0
- package/lib/module/shared/hooks/navigation/use-screen-state.js.map +1 -0
- package/lib/module/shared/hooks/use-stable-callback-value.js +0 -3
- package/lib/module/shared/hooks/use-stable-callback-value.js.map +1 -1
- package/lib/module/shared/index.js +1 -0
- package/lib/module/shared/index.js.map +1 -1
- package/lib/module/shared/providers/screen/keys.provider.js +0 -2
- package/lib/module/shared/providers/screen/keys.provider.js.map +1 -1
- package/lib/module/shared/providers/screen/screen-composer.js +3 -3
- package/lib/module/shared/providers/screen/screen-composer.js.map +1 -1
- package/lib/module/shared/providers/screen/styles.provider.js +1 -1
- package/lib/module/shared/providers/screen/styles.provider.js.map +1 -1
- package/lib/module/shared/types/index.js +1 -1
- package/lib/module/shared/types/index.js.map +1 -1
- package/lib/module/shared/types/stack.types.js +5 -0
- package/lib/module/shared/types/stack.types.js.map +1 -1
- package/lib/module/shared/utils/animation/start-screen-transition.js +1 -1
- package/lib/module/shared/utils/animation/start-screen-transition.js.map +1 -1
- package/lib/module/shared/utils/bounds/index.js.map +1 -1
- package/lib/typescript/blank-stack/components/stack-view.d.ts.map +1 -1
- package/lib/typescript/blank-stack/components/stack-view.native.d.ts.map +1 -1
- package/lib/typescript/blank-stack/types.d.ts +4 -8
- package/lib/typescript/blank-stack/types.d.ts.map +1 -1
- package/lib/typescript/component-stack/components/stack-view.d.ts.map +1 -1
- package/lib/typescript/component-stack/types.d.ts +4 -8
- package/lib/typescript/component-stack/types.d.ts.map +1 -1
- package/lib/typescript/native-stack/types.d.ts +2 -3
- package/lib/typescript/native-stack/types.d.ts.map +1 -1
- package/lib/typescript/native-stack/views/NativeStackView.native.d.ts.map +1 -1
- package/lib/typescript/shared/components/overlay/variations/float-overlay.d.ts.map +1 -1
- package/lib/typescript/shared/components/overlay/variations/overlay-host.d.ts +1 -6
- package/lib/typescript/shared/components/overlay/variations/overlay-host.d.ts.map +1 -1
- package/lib/typescript/shared/components/overlay/variations/screen-overlay.d.ts +4 -0
- package/lib/typescript/shared/components/overlay/variations/screen-overlay.d.ts.map +1 -1
- package/lib/typescript/shared/components/screen-lifecycle.d.ts +9 -0
- package/lib/typescript/shared/components/screen-lifecycle.d.ts.map +1 -0
- package/lib/typescript/shared/constants.d.ts +2 -1
- package/lib/typescript/shared/constants.d.ts.map +1 -1
- package/lib/typescript/shared/hooks/animation/use-screen-animation.d.ts.map +1 -1
- package/lib/typescript/shared/hooks/gestures/use-build-gestures.d.ts.map +1 -1
- package/lib/typescript/shared/hooks/navigation/use-screen-state.d.ts +40 -0
- package/lib/typescript/shared/hooks/navigation/use-screen-state.d.ts.map +1 -0
- package/lib/typescript/shared/hooks/use-stable-callback-value.d.ts.map +1 -1
- package/lib/typescript/shared/index.d.ts +21 -20
- package/lib/typescript/shared/index.d.ts.map +1 -1
- package/lib/typescript/shared/providers/screen/keys.provider.d.ts +2 -3
- package/lib/typescript/shared/providers/screen/keys.provider.d.ts.map +1 -1
- package/lib/typescript/shared/providers/screen/screen-composer.d.ts +1 -3
- package/lib/typescript/shared/providers/screen/screen-composer.d.ts.map +1 -1
- package/lib/typescript/shared/types/animation.types.d.ts +2 -6
- package/lib/typescript/shared/types/animation.types.d.ts.map +1 -1
- package/lib/typescript/shared/types/index.d.ts +2 -2
- package/lib/typescript/shared/types/index.d.ts.map +1 -1
- package/lib/typescript/shared/types/overlay.types.d.ts +21 -0
- package/lib/typescript/shared/types/overlay.types.d.ts.map +1 -1
- package/lib/typescript/shared/types/screen.types.d.ts +5 -4
- package/lib/typescript/shared/types/screen.types.d.ts.map +1 -1
- package/lib/typescript/shared/types/stack.types.d.ts +9 -0
- package/lib/typescript/shared/types/stack.types.d.ts.map +1 -1
- package/lib/typescript/shared/utils/animation/start-screen-transition.d.ts.map +1 -1
- package/lib/typescript/shared/utils/bounds/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/blank-stack/components/stack-view.native.tsx +0 -2
- package/src/blank-stack/components/stack-view.tsx +0 -2
- package/src/blank-stack/types.ts +6 -8
- package/src/component-stack/components/stack-view.tsx +19 -23
- package/src/component-stack/types.ts +7 -8
- package/src/native-stack/types.ts +2 -3
- package/src/native-stack/views/NativeStackView.native.tsx +2 -3
- package/src/shared/components/overlay/variations/float-overlay.tsx +2 -8
- package/src/shared/components/overlay/variations/overlay-host.tsx +18 -84
- package/src/shared/components/overlay/variations/screen-overlay.tsx +6 -15
- package/src/shared/components/screen-lifecycle.tsx +168 -0
- package/src/shared/constants.ts +3 -1
- package/src/shared/hooks/animation/use-screen-animation.tsx +3 -3
- package/src/shared/hooks/gestures/use-build-gestures.tsx +0 -2
- package/src/shared/hooks/navigation/use-screen-state.tsx +99 -0
- package/src/shared/hooks/use-stable-callback-value.ts +0 -1
- package/src/shared/index.ts +4 -0
- package/src/shared/providers/screen/keys.provider.tsx +1 -9
- package/src/shared/providers/screen/screen-composer.tsx +3 -5
- package/src/shared/providers/screen/styles.provider.tsx +1 -1
- package/src/shared/types/animation.types.ts +2 -6
- package/src/shared/types/index.ts +2 -7
- package/src/shared/types/overlay.types.ts +23 -0
- package/src/shared/types/screen.types.ts +5 -4
- package/src/shared/types/stack.types.ts +16 -1
- package/src/shared/utils/animation/start-screen-transition.ts +1 -1
- package/src/shared/utils/bounds/index.ts +6 -1
- package/lib/commonjs/native-stack/controllers/native-stack-lifecycle.js +0 -90
- package/lib/commonjs/native-stack/controllers/native-stack-lifecycle.js.map +0 -1
- package/lib/commonjs/shared/controller/managed-lifecycle.js +0 -78
- package/lib/commonjs/shared/controller/managed-lifecycle.js.map +0 -1
- package/lib/commonjs/shared/types/state.types.js +0 -9
- package/lib/commonjs/shared/types/state.types.js.map +0 -1
- package/lib/module/native-stack/controllers/native-stack-lifecycle.js +0 -83
- package/lib/module/native-stack/controllers/native-stack-lifecycle.js.map +0 -1
- package/lib/module/shared/controller/managed-lifecycle.js +0 -72
- package/lib/module/shared/controller/managed-lifecycle.js.map +0 -1
- package/lib/module/shared/types/state.types.js +0 -5
- package/lib/module/shared/types/state.types.js.map +0 -1
- package/lib/typescript/native-stack/controllers/native-stack-lifecycle.d.ts +0 -8
- package/lib/typescript/native-stack/controllers/native-stack-lifecycle.d.ts.map +0 -1
- package/lib/typescript/shared/controller/managed-lifecycle.d.ts +0 -9
- package/lib/typescript/shared/controller/managed-lifecycle.d.ts.map +0 -1
- package/lib/typescript/shared/types/state.types.d.ts +0 -3
- package/lib/typescript/shared/types/state.types.d.ts.map +0 -1
- package/src/native-stack/controllers/native-stack-lifecycle.tsx +0 -96
- package/src/shared/controller/managed-lifecycle.tsx +0 -73
- package/src/shared/types/state.types.ts +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"screen.types.d.ts","sourceRoot":"","sources":["../../../../src/shared/types/screen.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EACX,uBAAuB,EACvB,cAAc,EACd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAC/E,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEjE,MAAM,MAAM,MAAM,GAAG;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC;AAE/B,MAAM,MAAM,oBAAoB,CAAC,CAAC,SAAS,MAAM,IAAI,aAAa,CAAC,CAAC,CAAC,GAAG;IACvE;;;;;;;;;;;;;;;;;;;OAmBG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;;;;;;;;;;;;OAcG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACpC;;OAEG;IACH,uBAAuB,CAAC,EAAE,uBAAuB,CAAC;IAElD;;OAEG;IACH,cAAc,CAAC,EAAE,cAAc,CAAC;IAEhC;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB;;OAEG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,GAAG,gBAAgB,EAAE,CAAC;IAEzD;;OAEG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAE/B;;OAEG;IACH,uBAAuB,CAAC,EAAE,MAAM,CAAC;IAEjC;;OAEG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAEhC;;OAEG;IACH,qBAAqB,CAAC,EAAE,qBAAqB,CAAC;IAE9C;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAE/B;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,KAAK,CAAC,SAAS,CAAC;IAEnD
|
|
1
|
+
{"version":3,"file":"screen.types.d.ts","sourceRoot":"","sources":["../../../../src/shared/types/screen.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EACX,uBAAuB,EACvB,cAAc,EACd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAC/E,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEjE,MAAM,MAAM,MAAM,GAAG;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC;AAE/B,MAAM,MAAM,oBAAoB,CAAC,CAAC,SAAS,MAAM,IAAI,aAAa,CAAC,CAAC,CAAC,GAAG;IACvE;;;;;;;;;;;;;;;;;;;OAmBG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;;;;;;;;;;;;OAcG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACpC;;OAEG;IACH,uBAAuB,CAAC,EAAE,uBAAuB,CAAC;IAElD;;OAEG;IACH,cAAc,CAAC,EAAE,cAAc,CAAC;IAEhC;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB;;OAEG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,GAAG,gBAAgB,EAAE,CAAC;IAEzD;;OAEG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAE/B;;OAEG;IACH,uBAAuB,CAAC,EAAE,MAAM,CAAC;IAEjC;;OAEG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAEhC;;OAEG;IACH,qBAAqB,CAAC,EAAE,qBAAqB,CAAC;IAE9C;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAE/B;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,KAAK,CAAC,SAAS,CAAC;IAEnD;;;;;;;OAOG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;IAE1B;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB;;;;;;;;;OASG;IACH,kCAAkC,CAAC,EAAE,OAAO,CAAC;CAC7C,CAAC"}
|
|
@@ -18,8 +18,10 @@ export interface BaseStackNavigation {
|
|
|
18
18
|
key: string;
|
|
19
19
|
}>;
|
|
20
20
|
key: string;
|
|
21
|
+
index: number;
|
|
21
22
|
};
|
|
22
23
|
dispatch: (action: any) => void;
|
|
24
|
+
addListener?: (event: any, callback: any) => () => void;
|
|
23
25
|
}
|
|
24
26
|
/**
|
|
25
27
|
* Base descriptor interface - generic over route, navigation, and options.
|
|
@@ -48,6 +50,13 @@ export interface BaseStackState<TRoute extends BaseStackRoute = BaseStackRoute>
|
|
|
48
50
|
index: number;
|
|
49
51
|
key: string;
|
|
50
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Generic descriptor map - keyed by route key.
|
|
55
|
+
* Use this instead of defining stack-specific DescriptorMap types.
|
|
56
|
+
*/
|
|
57
|
+
export type DescriptorMap<TDescriptor extends BaseStackDescriptor = BaseStackDescriptor> = {
|
|
58
|
+
[key: string]: TDescriptor;
|
|
59
|
+
};
|
|
51
60
|
export declare enum StackType {
|
|
52
61
|
NATIVE = "native",
|
|
53
62
|
BLANK = "blank",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stack.types.d.ts","sourceRoot":"","sources":["../../../../src/shared/types/stack.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAE7D;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IACnC,QAAQ,EAAE,MAAM;
|
|
1
|
+
{"version":3,"file":"stack.types.d.ts","sourceRoot":"","sources":["../../../../src/shared/types/stack.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAE7D;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IACnC,QAAQ,EAAE,MAAM;QACf,MAAM,EAAE,KAAK,CAAC;YAAE,GAAG,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;QAC/B,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,EAAE,MAAM,CAAC;KACd,CAAC;IACF,QAAQ,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;IAChC,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,KAAK,MAAM,IAAI,CAAC;CACxD;AAED;;;GAGG;AACH,MAAM,WAAW,mBAAmB,CACnC,MAAM,SAAS,cAAc,GAAG,cAAc,EAC9C,WAAW,SAAS,mBAAmB,GAAG,mBAAmB,EAC7D,QAAQ,SAAS,sBAAsB,GAAG,sBAAsB;IAEhE,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,WAAW,CAAC;IACxB,OAAO,EAAE,QAAQ,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,KAAK,CAAC,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC;CACxC;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc,CAC9B,WAAW,SAAS,mBAAmB,GAAG,mBAAmB;IAE7D,KAAK,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IAC5B,UAAU,EAAE,WAAW,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc,CAC9B,MAAM,SAAS,cAAc,GAAG,cAAc;IAE9C,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACZ;AAED;;;GAGG;AACH,MAAM,MAAM,aAAa,CACxB,WAAW,SAAS,mBAAmB,GAAG,mBAAmB,IAC1D;IACH,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CAAC;CAC3B,CAAC;AAEF,oBAAY,SAAS;IACpB,MAAM,WAAW;IACjB,KAAK,UAAU;IACf,SAAS,cAAc;CACvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start-screen-transition.d.ts","sourceRoot":"","sources":["../../../../../src/shared/utils/animation/start-screen-transition.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"start-screen-transition.d.ts","sourceRoot":"","sources":["../../../../../src/shared/utils/animation/start-screen-transition.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAGlE,UAAU,0BAA0B;IACnC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;IACzB,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,iBAAiB,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;IAChD,UAAU,EAAE,iBAAiB,CAAC;IAC9B,iFAAiF;IACjF,eAAe,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,eAAO,MAAM,qBAAqB,GAAI,mEAMnC,0BAA0B,SA0C5B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/shared/utils/bounds/index.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACX,wBAAwB,EAExB,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,cAAc,EAAc,MAAM,0BAA0B,CAAC;AAkK3E,eAAO,MAAM,YAAY,GACxB,OAAO,IAAI,CAAC,wBAAwB,EAAE,QAAQ,CAAC,KAC7C,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/shared/utils/bounds/index.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACX,wBAAwB,EAExB,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,cAAc,EAAc,MAAM,0BAA0B,CAAC;AAkK3E,eAAO,MAAM,YAAY,GACxB,OAAO,IAAI,CAAC,wBAAwB,EAAE,QAAQ,CAAC,KAC7C,cA+EF,CAAC"}
|
package/package.json
CHANGED
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
import * as React from "react";
|
|
6
6
|
import { Fragment } from "react";
|
|
7
7
|
import { Overlay } from "../../shared/components/overlay";
|
|
8
|
-
import { ManagedLifecycle } from "../../shared/controller/managed-lifecycle";
|
|
9
8
|
import { ScreenComposer } from "../../shared/providers/screen/screen-composer";
|
|
10
9
|
import { withStackCore } from "../../shared/providers/stack/core.provider";
|
|
11
10
|
import { withManagedStack } from "../../shared/providers/stack/managed.provider";
|
|
@@ -79,7 +78,6 @@ export const StackView = withStackCore(
|
|
|
79
78
|
previous={previousDescriptor}
|
|
80
79
|
current={descriptor}
|
|
81
80
|
next={nextDescriptor}
|
|
82
|
-
LifecycleController={ManagedLifecycle}
|
|
83
81
|
>
|
|
84
82
|
<SceneView key={route.key} descriptor={descriptor} />
|
|
85
83
|
</ScreenComposer>
|
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
import * as React from "react";
|
|
6
6
|
import { Fragment } from "react";
|
|
7
7
|
import { Overlay } from "../../shared/components/overlay";
|
|
8
|
-
import { ManagedLifecycle } from "../../shared/controller/managed-lifecycle";
|
|
9
8
|
import { ScreenComposer } from "../../shared/providers/screen/screen-composer";
|
|
10
9
|
import { withStackCore } from "../../shared/providers/stack/core.provider";
|
|
11
10
|
import { withManagedStack } from "../../shared/providers/stack/managed.provider";
|
|
@@ -79,7 +78,6 @@ export const StackView = withStackCore(
|
|
|
79
78
|
previous={previousDescriptor}
|
|
80
79
|
current={descriptor}
|
|
81
80
|
next={nextDescriptor}
|
|
82
|
-
LifecycleController={ManagedLifecycle}
|
|
83
81
|
>
|
|
84
82
|
<SceneView key={route.key} descriptor={descriptor} />
|
|
85
83
|
</ScreenComposer>
|
package/src/blank-stack/types.ts
CHANGED
|
@@ -4,7 +4,6 @@ import type {
|
|
|
4
4
|
NavigationHelpers,
|
|
5
5
|
NavigationProp,
|
|
6
6
|
ParamListBase,
|
|
7
|
-
Route,
|
|
8
7
|
RouteProp,
|
|
9
8
|
StackActionHelpers,
|
|
10
9
|
StackNavigationState,
|
|
@@ -13,6 +12,10 @@ import type {
|
|
|
13
12
|
} from "@react-navigation/native";
|
|
14
13
|
import type { ScreenTransitionConfig } from "../shared";
|
|
15
14
|
import type { OverlayProps } from "../shared/types/overlay.types";
|
|
15
|
+
import type {
|
|
16
|
+
BaseStackScene,
|
|
17
|
+
DescriptorMap,
|
|
18
|
+
} from "../shared/types/stack.types";
|
|
16
19
|
|
|
17
20
|
export type BlankStackNavigationEventMap = {};
|
|
18
21
|
|
|
@@ -52,10 +55,7 @@ export type BlankStackNavigationHelpers = NavigationHelpers<
|
|
|
52
55
|
BlankStackNavigationEventMap
|
|
53
56
|
>;
|
|
54
57
|
|
|
55
|
-
export type BlankStackScene =
|
|
56
|
-
route: Route<string>;
|
|
57
|
-
descriptor: BlankStackDescriptor;
|
|
58
|
-
};
|
|
58
|
+
export type BlankStackScene = BaseStackScene<BlankStackDescriptor>;
|
|
59
59
|
|
|
60
60
|
type BlankStackNavigationConfig = {
|
|
61
61
|
DISABLE_NATIVE_SCREENS?: boolean;
|
|
@@ -106,6 +106,4 @@ export type BlankStackDescriptor = Descriptor<
|
|
|
106
106
|
RouteProp<ParamListBase>
|
|
107
107
|
>;
|
|
108
108
|
|
|
109
|
-
export type BlankStackDescriptorMap =
|
|
110
|
-
[key: string]: BlankStackDescriptor;
|
|
111
|
-
};
|
|
109
|
+
export type BlankStackDescriptorMap = DescriptorMap<BlankStackDescriptor>;
|
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
import * as React from "react";
|
|
6
6
|
import { Fragment } from "react";
|
|
7
7
|
import { Overlay } from "../../shared/components/overlay";
|
|
8
|
-
import { ManagedLifecycle } from "../../shared/controller/managed-lifecycle";
|
|
9
8
|
import { ScreenComposer } from "../../shared/providers/screen/screen-composer";
|
|
10
9
|
import { withStackCore } from "../../shared/providers/stack/core.provider";
|
|
11
10
|
import { withManagedStack } from "../../shared/providers/stack/managed.provider";
|
|
@@ -43,30 +42,27 @@ export const StackView = withStackCore(
|
|
|
43
42
|
<Fragment>
|
|
44
43
|
{shouldShowFloatOverlay ? <Overlay.Float /> : null}
|
|
45
44
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const route = scene.route;
|
|
45
|
+
{scenes.map((scene, sceneIndex) => {
|
|
46
|
+
const descriptor = scene.descriptor;
|
|
47
|
+
const route = scene.route;
|
|
50
48
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
49
|
+
const previousDescriptor =
|
|
50
|
+
scenes[sceneIndex - 1]?.descriptor ?? undefined;
|
|
51
|
+
const nextDescriptor =
|
|
52
|
+
scenes[sceneIndex + 1]?.descriptor ?? undefined;
|
|
55
53
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
})}
|
|
69
|
-
</Fragment>
|
|
54
|
+
return (
|
|
55
|
+
<ComponentScreen key={route.key} routeKey={route.key}>
|
|
56
|
+
<ScreenComposer
|
|
57
|
+
previous={previousDescriptor}
|
|
58
|
+
current={descriptor}
|
|
59
|
+
next={nextDescriptor}
|
|
60
|
+
>
|
|
61
|
+
<SceneView key={route.key} descriptor={descriptor} />
|
|
62
|
+
</ScreenComposer>
|
|
63
|
+
</ComponentScreen>
|
|
64
|
+
);
|
|
65
|
+
})}
|
|
70
66
|
</Fragment>
|
|
71
67
|
);
|
|
72
68
|
},
|
|
@@ -4,7 +4,6 @@ import type {
|
|
|
4
4
|
NavigationHelpers,
|
|
5
5
|
NavigationProp,
|
|
6
6
|
ParamListBase,
|
|
7
|
-
Route,
|
|
8
7
|
RouteProp,
|
|
9
8
|
StackActionHelpers,
|
|
10
9
|
StackNavigationState,
|
|
@@ -13,6 +12,10 @@ import type {
|
|
|
13
12
|
} from "@react-navigation/native";
|
|
14
13
|
import type { ScreenTransitionConfig } from "../shared";
|
|
15
14
|
import type { OverlayProps } from "../shared/types/overlay.types";
|
|
15
|
+
import type {
|
|
16
|
+
BaseStackScene,
|
|
17
|
+
DescriptorMap,
|
|
18
|
+
} from "../shared/types/stack.types";
|
|
16
19
|
|
|
17
20
|
export type ComponentStackNavigationEventMap = {};
|
|
18
21
|
|
|
@@ -52,10 +55,7 @@ export type ComponentStackNavigationHelpers = NavigationHelpers<
|
|
|
52
55
|
ComponentStackNavigationEventMap
|
|
53
56
|
>;
|
|
54
57
|
|
|
55
|
-
export type ComponentStackScene =
|
|
56
|
-
route: Route<string>;
|
|
57
|
-
descriptor: ComponentStackDescriptor;
|
|
58
|
-
};
|
|
58
|
+
export type ComponentStackScene = BaseStackScene<ComponentStackDescriptor>;
|
|
59
59
|
|
|
60
60
|
type ComponentStackNavigationConfig = {};
|
|
61
61
|
|
|
@@ -96,6 +96,5 @@ export type ComponentStackDescriptor = Descriptor<
|
|
|
96
96
|
RouteProp<ParamListBase>
|
|
97
97
|
>;
|
|
98
98
|
|
|
99
|
-
export type ComponentStackDescriptorMap =
|
|
100
|
-
|
|
101
|
-
};
|
|
99
|
+
export type ComponentStackDescriptorMap =
|
|
100
|
+
DescriptorMap<ComponentStackDescriptor>;
|
|
@@ -24,6 +24,7 @@ import type {
|
|
|
24
24
|
} from "react-native-screens";
|
|
25
25
|
import type { OverlayProps } from "../shared/types/overlay.types";
|
|
26
26
|
import type { ScreenTransitionConfig } from "../shared/types/screen.types";
|
|
27
|
+
import type { DescriptorMap } from "../shared/types/stack.types";
|
|
27
28
|
|
|
28
29
|
export type NativeStackNavigationEventMap = {
|
|
29
30
|
/**
|
|
@@ -717,6 +718,4 @@ export type NativeStackDescriptor = Descriptor<
|
|
|
717
718
|
RouteProp<ParamListBase>
|
|
718
719
|
>;
|
|
719
720
|
|
|
720
|
-
export type NativeStackDescriptorMap =
|
|
721
|
-
[key: string]: NativeStackDescriptor;
|
|
722
|
-
};
|
|
721
|
+
export type NativeStackDescriptorMap = DescriptorMap<NativeStackDescriptor>;
|
|
@@ -35,7 +35,7 @@ import {
|
|
|
35
35
|
type DirectStackContextValue,
|
|
36
36
|
withDirectStack,
|
|
37
37
|
} from "../../shared/providers/stack/direct.provider";
|
|
38
|
-
import {
|
|
38
|
+
import { StackType } from "../../shared/types/stack.types";
|
|
39
39
|
import type { NativeStackDescriptor } from "../types";
|
|
40
40
|
import { debounce } from "../utils/debounce";
|
|
41
41
|
import { getModalRouteKeys } from "../utils/getModalRoutesKeys";
|
|
@@ -468,7 +468,6 @@ const SceneView = ({
|
|
|
468
468
|
previous={previousDescriptor}
|
|
469
469
|
current={descriptor}
|
|
470
470
|
next={nextDescriptor}
|
|
471
|
-
LifecycleController={NativeStackScreenLifecycleController}
|
|
472
471
|
>
|
|
473
472
|
{render()}
|
|
474
473
|
</ScreenComposer>
|
|
@@ -483,7 +482,7 @@ const SceneView = ({
|
|
|
483
482
|
};
|
|
484
483
|
|
|
485
484
|
export const NativeStackView = withStackCore(
|
|
486
|
-
{ TRANSITIONS_ALWAYS_ON: false },
|
|
485
|
+
{ TRANSITIONS_ALWAYS_ON: false, STACK_TYPE: StackType.NATIVE },
|
|
487
486
|
withDirectStack(function NativeStackViewContent({
|
|
488
487
|
state,
|
|
489
488
|
navigation,
|
|
@@ -10,7 +10,7 @@ import { OverlayHost } from "./overlay-host";
|
|
|
10
10
|
* Gets routes and descriptors from stack context.
|
|
11
11
|
*/
|
|
12
12
|
export function FloatOverlay() {
|
|
13
|
-
const {
|
|
13
|
+
const { scenes, focusedIndex, flags } = useStack();
|
|
14
14
|
|
|
15
15
|
const activeOverlay = useMemo(
|
|
16
16
|
() =>
|
|
@@ -31,13 +31,7 @@ export function FloatOverlay() {
|
|
|
31
31
|
return (
|
|
32
32
|
<KeysProvider current={current} previous={previous} next={next}>
|
|
33
33
|
<ScreenStylesProvider>
|
|
34
|
-
<OverlayHost
|
|
35
|
-
scene={scene}
|
|
36
|
-
scenes={scenes}
|
|
37
|
-
routes={routes}
|
|
38
|
-
overlayIndex={overlayIndex}
|
|
39
|
-
isFloating
|
|
40
|
-
/>
|
|
34
|
+
<OverlayHost scene={scene} />
|
|
41
35
|
</ScreenStylesProvider>
|
|
42
36
|
</KeysProvider>
|
|
43
37
|
);
|
|
@@ -1,131 +1,65 @@
|
|
|
1
1
|
import {
|
|
2
2
|
NavigationContext,
|
|
3
3
|
NavigationRouteContext,
|
|
4
|
-
type Route,
|
|
5
4
|
} from "@react-navigation/native";
|
|
6
5
|
import { memo, useMemo } from "react";
|
|
7
6
|
import { Animated, StyleSheet, useWindowDimensions, View } from "react-native";
|
|
8
7
|
import { useDerivedValue } from "react-native-reanimated";
|
|
9
8
|
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
10
9
|
import { useScreenAnimation } from "../../../hooks/animation/use-screen-animation";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
10
|
+
import { useScreenState } from "../../../hooks/navigation/use-screen-state";
|
|
11
|
+
import type { StackScene } from "../../../hooks/navigation/use-stack";
|
|
12
|
+
import type { BaseDescriptor } from "../../../providers/screen/keys.provider";
|
|
13
13
|
import type { OverlayInterpolationProps } from "../../../types/animation.types";
|
|
14
14
|
import type { OverlayProps } from "../../../types/overlay.types";
|
|
15
15
|
|
|
16
16
|
type OverlayHostProps = {
|
|
17
17
|
scene: StackScene;
|
|
18
|
-
scenes: StackScene[];
|
|
19
|
-
routes: Route<string>[];
|
|
20
|
-
overlayIndex: number;
|
|
21
|
-
isFloating?: boolean;
|
|
22
18
|
};
|
|
23
19
|
|
|
24
20
|
export const OverlayHost = memo(function OverlayHost({
|
|
25
21
|
scene,
|
|
26
|
-
scenes,
|
|
27
|
-
routes,
|
|
28
|
-
overlayIndex,
|
|
29
|
-
isFloating,
|
|
30
22
|
}: OverlayHostProps) {
|
|
31
23
|
const OverlayComponent = scene.descriptor.options.overlay;
|
|
32
24
|
const screen = useWindowDimensions();
|
|
33
|
-
|
|
34
|
-
const { stackProgress, optimisticFocusedIndex, routeKeys } = useStack();
|
|
35
25
|
const insets = useSafeAreaInsets();
|
|
36
26
|
|
|
27
|
+
const screenAnimation = useScreenAnimation();
|
|
28
|
+
const screenState = useScreenState();
|
|
37
29
|
const relativeProgress = useDerivedValue(() => {
|
|
38
30
|
"worklet";
|
|
39
|
-
return
|
|
31
|
+
return screenAnimation.value.stackProgress;
|
|
40
32
|
});
|
|
41
33
|
|
|
42
|
-
// For float overlays: global focused index (can be any screen in the stack)
|
|
43
|
-
// For screen overlays: relative to overlay position (only screens at or after)
|
|
44
|
-
const optimisticActiveIndex = useSharedValueState(
|
|
45
|
-
useDerivedValue(() => {
|
|
46
|
-
"worklet";
|
|
47
|
-
if (isFloating) {
|
|
48
|
-
// For float overlays, use global optimistic focused index directly
|
|
49
|
-
const globalIndex = optimisticFocusedIndex.get();
|
|
50
|
-
const clampedIndex = Math.max(
|
|
51
|
-
0,
|
|
52
|
-
Math.min(globalIndex, routeKeys.length - 1),
|
|
53
|
-
);
|
|
54
|
-
return clampedIndex;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// For screen overlays, compute relative to overlay position
|
|
58
|
-
const screensAbove = routeKeys.length - 1 - overlayIndex;
|
|
59
|
-
const relativeOptimistic = optimisticFocusedIndex.value - overlayIndex;
|
|
60
|
-
const result = Math.max(0, Math.min(relativeOptimistic, screensAbove));
|
|
61
|
-
|
|
62
|
-
return result;
|
|
63
|
-
}),
|
|
64
|
-
);
|
|
65
|
-
|
|
66
34
|
const overlayAnimation = useDerivedValue<OverlayInterpolationProps>(() => ({
|
|
67
35
|
progress: relativeProgress.value,
|
|
68
36
|
layouts: { screen },
|
|
69
37
|
insets,
|
|
70
38
|
}));
|
|
71
39
|
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
// For screen overlays, optimisticActiveIndex is relative to overlayIndex
|
|
83
|
-
const maxOffset = Math.max(scenes.length - overlayIndex - 1, 0);
|
|
84
|
-
const normalizedIndex = Math.min(
|
|
85
|
-
Math.max(optimisticActiveIndex, 0),
|
|
86
|
-
maxOffset,
|
|
87
|
-
);
|
|
88
|
-
|
|
89
|
-
return scenes[overlayIndex + normalizedIndex] ?? scene;
|
|
90
|
-
}, [overlayIndex, optimisticActiveIndex, scenes, scene, isFloating]);
|
|
91
|
-
|
|
92
|
-
const screenAnimation = useScreenAnimation();
|
|
40
|
+
const overlayProps: OverlayProps<BaseDescriptor["navigation"]> = useMemo(
|
|
41
|
+
() => ({
|
|
42
|
+
...screenState,
|
|
43
|
+
progress: relativeProgress,
|
|
44
|
+
overlayAnimation, //Deprecated
|
|
45
|
+
screenAnimation, //Deprecated
|
|
46
|
+
}),
|
|
47
|
+
[relativeProgress, overlayAnimation, screenAnimation, screenState],
|
|
48
|
+
);
|
|
93
49
|
|
|
94
50
|
if (!OverlayComponent) {
|
|
95
51
|
return null;
|
|
96
52
|
}
|
|
97
53
|
|
|
98
|
-
const overlayProps: OverlayProps<typeof scene.descriptor.navigation> = {
|
|
99
|
-
routes,
|
|
100
|
-
overlayAnimation,
|
|
101
|
-
screenAnimation,
|
|
102
|
-
focusedRoute: focusedScene.route,
|
|
103
|
-
focusedIndex: optimisticActiveIndex,
|
|
104
|
-
meta: focusedScene.descriptor.options.meta,
|
|
105
|
-
navigation: scene.descriptor.navigation,
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
// Cast to OverlayProps function - container overlays are handled by ContainerOverlay component
|
|
109
|
-
const renderOverlay = OverlayComponent as (
|
|
110
|
-
props: OverlayProps,
|
|
111
|
-
) => React.ReactNode;
|
|
112
|
-
|
|
113
54
|
return (
|
|
114
55
|
<Animated.View
|
|
115
56
|
pointerEvents="box-none"
|
|
116
|
-
style={[
|
|
117
|
-
styles.container,
|
|
118
|
-
isFloating ? styles.floating : { zIndex: 1 },
|
|
119
|
-
styles.absolute,
|
|
120
|
-
]}
|
|
57
|
+
style={[styles.container, styles.floating, styles.absolute]}
|
|
121
58
|
>
|
|
122
|
-
<NavigationContext.Provider
|
|
123
|
-
// biome-ignore lint/suspicious/noExplicitAny: navigation type varies by stack
|
|
124
|
-
value={scene.descriptor.navigation as any}
|
|
125
|
-
>
|
|
59
|
+
<NavigationContext.Provider value={scene.descriptor.navigation as any}>
|
|
126
60
|
<NavigationRouteContext.Provider value={scene.route}>
|
|
127
61
|
<View pointerEvents="box-none" style={styles.overlay}>
|
|
128
|
-
{
|
|
62
|
+
<OverlayComponent {...overlayProps} />
|
|
129
63
|
</View>
|
|
130
64
|
</NavigationRouteContext.Provider>
|
|
131
65
|
</NavigationContext.Provider>
|
|
@@ -10,10 +10,14 @@ import { OverlayHost } from "./overlay-host";
|
|
|
10
10
|
/**
|
|
11
11
|
* Screen overlay component that renders per-screen.
|
|
12
12
|
* Gets current descriptor from keys context.
|
|
13
|
+
*
|
|
14
|
+
* @deprecated Screen overlays are deprecated. For per-screen overlays, render an
|
|
15
|
+
* absolute-positioned view directly in your screen component and use `useScreenAnimation()`
|
|
16
|
+
* to access animation values. This component will be removed in a future version.
|
|
13
17
|
*/
|
|
14
18
|
export function ScreenOverlay() {
|
|
15
19
|
const { current } = useKeys<StackDescriptor>();
|
|
16
|
-
const {
|
|
20
|
+
const { flags } = useStack();
|
|
17
21
|
|
|
18
22
|
const options = current.options;
|
|
19
23
|
|
|
@@ -25,12 +29,6 @@ export function ScreenOverlay() {
|
|
|
25
29
|
[current],
|
|
26
30
|
);
|
|
27
31
|
|
|
28
|
-
// Find the index of this screen in the stack
|
|
29
|
-
const overlayIndex = useMemo(
|
|
30
|
-
() => routeKeys.indexOf(current.route.key),
|
|
31
|
-
[routeKeys, current.route.key],
|
|
32
|
-
);
|
|
33
|
-
|
|
34
32
|
// Skip screens without enableTransitions (native-stack only)
|
|
35
33
|
if (!flags.TRANSITIONS_ALWAYS_ON && !options.enableTransitions) {
|
|
36
34
|
return null;
|
|
@@ -40,12 +38,5 @@ export function ScreenOverlay() {
|
|
|
40
38
|
return null;
|
|
41
39
|
}
|
|
42
40
|
|
|
43
|
-
return
|
|
44
|
-
<OverlayHost
|
|
45
|
-
scene={scene}
|
|
46
|
-
scenes={[scene]}
|
|
47
|
-
routes={[]}
|
|
48
|
-
overlayIndex={overlayIndex}
|
|
49
|
-
/>
|
|
50
|
-
);
|
|
41
|
+
return <OverlayHost scene={scene} />;
|
|
51
42
|
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { useLayoutEffect } from "react";
|
|
2
|
+
import {
|
|
3
|
+
runOnJS,
|
|
4
|
+
useAnimatedReaction,
|
|
5
|
+
useDerivedValue,
|
|
6
|
+
} from "react-native-reanimated";
|
|
7
|
+
import { useHighRefreshRate } from "../hooks/animation/use-high-refresh-rate";
|
|
8
|
+
import { useSharedValueState } from "../hooks/reanimated/use-shared-value-state";
|
|
9
|
+
import useStableCallback from "../hooks/use-stable-callback";
|
|
10
|
+
import { useGestureContext } from "../providers/gestures.provider";
|
|
11
|
+
import {
|
|
12
|
+
type BaseDescriptor,
|
|
13
|
+
useKeys,
|
|
14
|
+
} from "../providers/screen/keys.provider";
|
|
15
|
+
import { useStackCoreContext } from "../providers/stack/core.provider";
|
|
16
|
+
import { useManagedStackContext } from "../providers/stack/managed.provider";
|
|
17
|
+
import { AnimationStore } from "../stores/animation.store";
|
|
18
|
+
import { StackType } from "../types/stack.types";
|
|
19
|
+
import { startScreenTransition } from "../utils/animation/start-screen-transition";
|
|
20
|
+
import { resetStoresForScreen } from "../utils/reset-stores-for-screen";
|
|
21
|
+
|
|
22
|
+
interface Props {
|
|
23
|
+
children: React.ReactNode;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface CloseHookParams {
|
|
27
|
+
current: BaseDescriptor;
|
|
28
|
+
animations: ReturnType<typeof AnimationStore.getAll>;
|
|
29
|
+
activate: () => void;
|
|
30
|
+
deactivate: () => void;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Managed close - reacts to closingRouteKeysShared from ManagedStackContext.
|
|
35
|
+
* Used by blank-stack and component-stack.
|
|
36
|
+
*/
|
|
37
|
+
const useManagedClose = ({
|
|
38
|
+
current,
|
|
39
|
+
animations,
|
|
40
|
+
activate,
|
|
41
|
+
deactivate,
|
|
42
|
+
}: CloseHookParams) => {
|
|
43
|
+
const { handleCloseRoute, closingRouteKeysShared } = useManagedStackContext();
|
|
44
|
+
|
|
45
|
+
const handleCloseEnd = useStableCallback((finished: boolean) => {
|
|
46
|
+
if (!finished) return;
|
|
47
|
+
handleCloseRoute({ route: current.route });
|
|
48
|
+
requestAnimationFrame(() => {
|
|
49
|
+
deactivate();
|
|
50
|
+
resetStoresForScreen(current);
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
useAnimatedReaction(
|
|
55
|
+
() => closingRouteKeysShared.value,
|
|
56
|
+
(keys) => {
|
|
57
|
+
if (!keys?.includes(current.route.key)) return;
|
|
58
|
+
|
|
59
|
+
runOnJS(activate)();
|
|
60
|
+
startScreenTransition({
|
|
61
|
+
target: "close",
|
|
62
|
+
spec: current.options.transitionSpec,
|
|
63
|
+
animations,
|
|
64
|
+
onAnimationFinish: handleCloseEnd,
|
|
65
|
+
});
|
|
66
|
+
},
|
|
67
|
+
);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Native stack close - listens to beforeRemove navigation event.
|
|
72
|
+
*/
|
|
73
|
+
const useNativeStackClose = ({
|
|
74
|
+
current,
|
|
75
|
+
animations,
|
|
76
|
+
activate,
|
|
77
|
+
deactivate,
|
|
78
|
+
}: CloseHookParams) => {
|
|
79
|
+
const gestureCtx = useGestureContext();
|
|
80
|
+
|
|
81
|
+
const isAncestorDismissingViaGesture = useSharedValueState(
|
|
82
|
+
useDerivedValue(() => {
|
|
83
|
+
"worklet";
|
|
84
|
+
return (
|
|
85
|
+
gestureCtx?.ancestorContext?.gestureAnimationValues.isDismissing
|
|
86
|
+
?.value ?? false
|
|
87
|
+
);
|
|
88
|
+
}),
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
const handleBeforeRemove = useStableCallback((e: any) => {
|
|
92
|
+
const options = current.options as { enableTransitions?: boolean };
|
|
93
|
+
const isEnabled = options.enableTransitions;
|
|
94
|
+
const navigation = current.navigation;
|
|
95
|
+
const isFirstScreen = navigation.getState().index === 0;
|
|
96
|
+
|
|
97
|
+
// If transitions are disabled, ancestor is dismissing, or first screen - let native handle it
|
|
98
|
+
if (!isEnabled || isAncestorDismissingViaGesture || isFirstScreen) {
|
|
99
|
+
animations.closing.set(1);
|
|
100
|
+
resetStoresForScreen(current);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
e.preventDefault();
|
|
105
|
+
activate();
|
|
106
|
+
|
|
107
|
+
startScreenTransition({
|
|
108
|
+
target: "close",
|
|
109
|
+
spec: current.options.transitionSpec,
|
|
110
|
+
animations,
|
|
111
|
+
onAnimationFinish: (finished: boolean) => {
|
|
112
|
+
deactivate();
|
|
113
|
+
if (finished) {
|
|
114
|
+
navigation.dispatch(e.data.action);
|
|
115
|
+
requestAnimationFrame(() => {
|
|
116
|
+
resetStoresForScreen(current);
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: Only re-subscribe when navigation changes
|
|
124
|
+
useLayoutEffect(() => {
|
|
125
|
+
return current.navigation.addListener?.("beforeRemove", handleBeforeRemove);
|
|
126
|
+
}, [current.navigation]);
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Unified lifecycle controller for all stack types.
|
|
131
|
+
*/
|
|
132
|
+
export const ScreenLifecycle = ({ children }: Props) => {
|
|
133
|
+
const { flags } = useStackCoreContext();
|
|
134
|
+
const { current } = useKeys();
|
|
135
|
+
const animations = AnimationStore.getAll(current.route.key);
|
|
136
|
+
const { activateHighRefreshRate, deactivateHighRefreshRate } =
|
|
137
|
+
useHighRefreshRate(current);
|
|
138
|
+
|
|
139
|
+
const isNativeStack = flags.STACK_TYPE === StackType.NATIVE;
|
|
140
|
+
|
|
141
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: Must only run once on mount
|
|
142
|
+
useLayoutEffect(() => {
|
|
143
|
+
activateHighRefreshRate();
|
|
144
|
+
startScreenTransition({
|
|
145
|
+
target: "open",
|
|
146
|
+
spec: current.options.transitionSpec,
|
|
147
|
+
animations,
|
|
148
|
+
onAnimationFinish: deactivateHighRefreshRate,
|
|
149
|
+
});
|
|
150
|
+
}, []);
|
|
151
|
+
|
|
152
|
+
const closeParams: CloseHookParams = {
|
|
153
|
+
current,
|
|
154
|
+
animations,
|
|
155
|
+
activate: activateHighRefreshRate,
|
|
156
|
+
deactivate: deactivateHighRefreshRate,
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
if (isNativeStack) {
|
|
160
|
+
// biome-ignore lint/correctness/useHookAtTopLevel: STACK_TYPE is stable per screen instance
|
|
161
|
+
useNativeStackClose(closeParams);
|
|
162
|
+
} else {
|
|
163
|
+
// biome-ignore lint/correctness/useHookAtTopLevel: STACK_TYPE is stable per screen instance
|
|
164
|
+
useManagedClose(closeParams);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return children;
|
|
168
|
+
};
|