@react-navigation/native-stack 8.0.0-alpha.4 → 8.0.0-alpha.41

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.
Files changed (43) hide show
  1. package/lib/module/index.js.map +1 -1
  2. package/lib/module/navigators/createNativeStackNavigator.js +4 -8
  3. package/lib/module/navigators/createNativeStackNavigator.js.map +1 -1
  4. package/lib/module/utils/useAnimatedHeaderHeight.js +1 -1
  5. package/lib/module/utils/useAnimatedHeaderHeight.js.map +1 -1
  6. package/lib/module/utils/useInvalidPreventRemoveError.js +1 -1
  7. package/lib/module/utils/useInvalidPreventRemoveError.js.map +1 -1
  8. package/lib/module/views/FooterComponent.js +1 -1
  9. package/lib/module/views/FooterComponent.js.map +1 -1
  10. package/lib/module/views/NativeStackView.js +42 -25
  11. package/lib/module/views/NativeStackView.js.map +1 -1
  12. package/lib/module/views/NativeStackView.native.js +113 -68
  13. package/lib/module/views/NativeStackView.native.js.map +1 -1
  14. package/lib/module/views/useHeaderConfigProps.js +71 -21
  15. package/lib/module/views/useHeaderConfigProps.js.map +1 -1
  16. package/lib/typescript/src/index.d.ts +3 -3
  17. package/lib/typescript/src/index.d.ts.map +1 -1
  18. package/lib/typescript/src/navigators/createNativeStackNavigator.d.ts +10 -15
  19. package/lib/typescript/src/navigators/createNativeStackNavigator.d.ts.map +1 -1
  20. package/lib/typescript/src/types.d.ts +145 -148
  21. package/lib/typescript/src/types.d.ts.map +1 -1
  22. package/lib/typescript/src/utils/getModalRoutesKeys.d.ts +1 -1
  23. package/lib/typescript/src/utils/getModalRoutesKeys.d.ts.map +1 -1
  24. package/lib/typescript/src/utils/useInvalidPreventRemoveError.d.ts +1 -1
  25. package/lib/typescript/src/utils/useInvalidPreventRemoveError.d.ts.map +1 -1
  26. package/lib/typescript/src/views/FooterComponent.d.ts +2 -2
  27. package/lib/typescript/src/views/FooterComponent.d.ts.map +1 -1
  28. package/lib/typescript/src/views/NativeStackView.d.ts +3 -2
  29. package/lib/typescript/src/views/NativeStackView.d.ts.map +1 -1
  30. package/lib/typescript/src/views/NativeStackView.native.d.ts +3 -2
  31. package/lib/typescript/src/views/NativeStackView.native.d.ts.map +1 -1
  32. package/lib/typescript/src/views/useHeaderConfigProps.d.ts +1 -1
  33. package/lib/typescript/src/views/useHeaderConfigProps.d.ts.map +1 -1
  34. package/package.json +18 -19
  35. package/src/index.tsx +1 -0
  36. package/src/navigators/createNativeStackNavigator.tsx +11 -47
  37. package/src/types.tsx +206 -186
  38. package/src/utils/useAnimatedHeaderHeight.tsx +1 -1
  39. package/src/utils/useInvalidPreventRemoveError.tsx +2 -1
  40. package/src/views/FooterComponent.tsx +1 -1
  41. package/src/views/NativeStackView.native.tsx +168 -89
  42. package/src/views/NativeStackView.tsx +70 -41
  43. package/src/views/useHeaderConfigProps.tsx +100 -36
@@ -1 +1 @@
1
- {"version":3,"names":["createNativeStackNavigator","createNativeStackScreen","NativeStackView","useAnimatedHeaderHeight"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA;AACA;AACA;AACA,SACEA,0BAA0B,EAC1BC,uBAAuB,QAClB,4CAAyC;;AAEhD;AACA;AACA;AACA,SAASC,eAAe,QAAQ,yBAAyB;;AAEzD;AACA;AACA;AACA,SAASC,uBAAuB,QAAQ,oCAAiC;;AAEzE;AACA;AACA","ignoreList":[]}
1
+ {"version":3,"names":["createNativeStackNavigator","createNativeStackScreen","NativeStackView","useAnimatedHeaderHeight"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA;AACA;AACA;AACA,SACEA,0BAA0B,EAC1BC,uBAAuB,QAElB,4CAAyC;;AAEhD;AACA;AACA;AACA,SAASC,eAAe,QAAQ,yBAAyB;;AAEzD;AACA;AACA;AACA,SAASC,uBAAuB,QAAQ,oCAAiC;;AAEzE;AACA;AACA","ignoreList":[]}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- import { createNavigatorFactory, NavigationMetaContext, StackActions, StackRouter, useNavigationBuilder } from '@react-navigation/native';
3
+ import { createNavigatorFactory, createScreenFactory, NavigationMetaContext, StackActions, StackRouter, useNavigationBuilder } from '@react-navigation/native';
4
4
  import * as React from 'react';
5
5
  import { NativeStackView } from '../views/NativeStackView';
6
6
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -30,7 +30,7 @@ function NativeStackNavigator({
30
30
  screenLayout,
31
31
  router
32
32
  });
33
- const meta = React.useContext(NavigationMetaContext);
33
+ const meta = React.use(NavigationMetaContext);
34
34
  React.useEffect(() => {
35
35
  if (meta && 'type' in meta && meta.type === 'native-tabs') {
36
36
  // If we're inside native tabs, we don't need to handle popToTop
@@ -65,10 +65,6 @@ function NativeStackNavigator({
65
65
  })
66
66
  });
67
67
  }
68
- export function createNativeStackNavigator(config) {
69
- return createNavigatorFactory(NativeStackNavigator)(config);
70
- }
71
- export function createNativeStackScreen(config) {
72
- return config;
73
- }
68
+ export const createNativeStackNavigator = createNavigatorFactory(NativeStackNavigator);
69
+ export const createNativeStackScreen = createScreenFactory();
74
70
  //# sourceMappingURL=createNativeStackNavigator.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createNavigatorFactory","NavigationMetaContext","StackActions","StackRouter","useNavigationBuilder","React","NativeStackView","jsx","_jsx","NativeStackNavigator","initialRouteName","routeNamesChangeBehavior","children","layout","screenListeners","screenOptions","screenLayout","router","rest","state","descriptors","navigation","NavigationContent","meta","useContext","useEffect","type","addListener","e","isFocused","requestAnimationFrame","index","defaultPrevented","dispatch","popToTop","target","key","createNativeStackNavigator","config","createNativeStackScreen"],"sourceRoot":"../../../src","sources":["navigators/createNativeStackNavigator.tsx"],"mappings":";;AAAA,SACEA,sBAAsB,EAEtBC,qBAAqB,EAGrBC,YAAY,EAEZC,WAAW,EAQXC,oBAAoB,QACf,0BAA0B;AACjC,OAAO,KAAKC,KAAK,MAAM,OAAO;AAQ9B,SAASC,eAAe,QAAQ,0BAA0B;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAE3D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MAAA,GACVY,IAAI;MACRC,KAAK,EAAEA,KAAM;MACbE,UAAU,EAAEA,UAAW;MACvBD,WAAW,EAAEA;IAAY,CAC1B;EAAC,CACe,CAAC;AAExB;AA2BA,OAAO,SAASiB,0BAA0BA,CAACC,MAAgB,EAAE;EAC3D,OAAOtC,sBAAsB,CAACS,oBAAoB,CAAC,CAAC6B,MAAM,CAAC;AAC7D;AAEA,OAAO,SAASC,uBAAuBA,CAIrCD,MAOC,EACD;EACA,OAAOA,MAAM;AACf","ignoreList":[]}
1
+ {"version":3,"names":["createNavigatorFactory","createScreenFactory","NavigationMetaContext","StackActions","StackRouter","useNavigationBuilder","React","NativeStackView","jsx","_jsx","NativeStackNavigator","initialRouteName","routeNamesChangeBehavior","children","layout","screenListeners","screenOptions","screenLayout","router","rest","state","descriptors","navigation","NavigationContent","meta","use","useEffect","type","addListener","e","isFocused","requestAnimationFrame","index","defaultPrevented","dispatch","popToTop","target","key","createNativeStackNavigator","createNativeStackScreen"],"sourceRoot":"../../../src","sources":["navigators/createNativeStackNavigator.tsx"],"mappings":";;AAAA,SACEA,sBAAsB,EACtBC,mBAAmB,EAEnBC,qBAAqB,EAIrBC,YAAY,EAEZC,WAAW,EAEXC,oBAAoB,QACf,0BAA0B;AACjC,OAAO,KAAKC,KAAK,MAAM,OAAO;AAO9B,SAASC,eAAe,QAAQ,0BAA0B;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAE3D,SAASC,oBAAoBA,CAAC;EAC5BC,gBAAgB;EAChBC,wBAAwB;EACxBC,QAAQ;EACRC,MAAM;EACNC,eAAe;EACfC,aAAa;EACbC,YAAY;EACZC,MAAM;EACN,GAAGC;AACsB,CAAC,EAAE;EAC5B,MAAM;IAAEC,KAAK;IAAEC,WAAW;IAAEC,UAAU;IAAEC;EAAkB,CAAC,GACzDlB,oBAAoB,CAMlBD,WAAW,EAAE;IACbO,gBAAgB;IAChBC,wBAAwB;IACxBC,QAAQ;IACRC,MAAM;IACNC,eAAe;IACfC,aAAa;IACbC,YAAY;IACZC;EACF,CAAC,CAAC;EAEJ,MAAMM,IAAI,GAAGlB,KAAK,CAACmB,GAAG,CAACvB,qBAAqB,CAAC;EAE7CI,KAAK,CAACoB,SAAS,CAAC,MAAM;IACpB,IAAIF,IAAI,IAAI,MAAM,IAAIA,IAAI,IAAIA,IAAI,CAACG,IAAI,KAAK,aAAa,EAAE;MACzD;MACA;MACA;IACF;;IAEA;IACA,OAAOL,UAAU,EAAEM,WAAW,GAAG,UAAU,EAAGC,CAAM,IAAK;MACvD,MAAMC,SAAS,GAAGR,UAAU,CAACQ,SAAS,CAAC,CAAC;;MAExC;MACA;MACAC,qBAAqB,CAAC,MAAM;QAC1B,IACEX,KAAK,CAACY,KAAK,GAAG,CAAC,IACfF,SAAS,IACT,CAAED,CAAC,CAAgCI,gBAAgB,EACnD;UACA;UACA;UACAX,UAAU,CAACY,QAAQ,CAAC;YAClB,GAAG/B,YAAY,CAACgC,QAAQ,CAAC,CAAC;YAC1BC,MAAM,EAAEhB,KAAK,CAACiB;UAChB,CAAC,CAAC;QACJ;MACF,CAAC,CAAC;IACJ,CAAC,CAAC;EACJ,CAAC,EAAE,CAACb,IAAI,EAAEF,UAAU,EAAEF,KAAK,CAACY,KAAK,EAAEZ,KAAK,CAACiB,GAAG,CAAC,CAAC;EAE9C,oBACE5B,IAAA,CAACc,iBAAiB;IAAAV,QAAA,eAChBJ,IAAA,CAACF,eAAe;MAAA,GACVY,IAAI;MACRC,KAAK,EAAEA,KAAM;MACbE,UAAU,EAAEA,UAAW;MACvBD,WAAW,EAAEA;IAAY,CAC1B;EAAC,CACe,CAAC;AAExB;AAUA,OAAO,MAAMiB,0BAA0B,GACrCtC,sBAAsB,CAAqBU,oBAAoB,CAAC;AAElE,OAAO,MAAM6B,uBAAuB,GAClCtC,mBAAmB,CAAqB,CAAC","ignoreList":[]}
@@ -3,7 +3,7 @@
3
3
  import * as React from 'react';
4
4
  export const AnimatedHeaderHeightContext = /*#__PURE__*/React.createContext(undefined);
5
5
  export function useAnimatedHeaderHeight() {
6
- const animatedValue = React.useContext(AnimatedHeaderHeightContext);
6
+ const animatedValue = React.use(AnimatedHeaderHeightContext);
7
7
  if (animatedValue === undefined) {
8
8
  throw new Error("Couldn't find the header height. Are you inside a screen in a native stack navigator?");
9
9
  }
@@ -1 +1 @@
1
- {"version":3,"names":["React","AnimatedHeaderHeightContext","createContext","undefined","useAnimatedHeaderHeight","animatedValue","useContext","Error"],"sourceRoot":"../../../src","sources":["utils/useAnimatedHeaderHeight.tsx"],"mappings":";;AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAG9B,OAAO,MAAMC,2BAA2B,gBAAGD,KAAK,CAACE,aAAa,CAE5DC,SAAS,CAAC;AAEZ,OAAO,SAASC,uBAAuBA,CAAA,EAAG;EACxC,MAAMC,aAAa,GAAGL,KAAK,CAACM,UAAU,CAACL,2BAA2B,CAAC;EAEnE,IAAII,aAAa,KAAKF,SAAS,EAAE;IAC/B,MAAM,IAAII,KAAK,CACb,uFACF,CAAC;EACH;EAEA,OAAOF,aAAa;AACtB","ignoreList":[]}
1
+ {"version":3,"names":["React","AnimatedHeaderHeightContext","createContext","undefined","useAnimatedHeaderHeight","animatedValue","use","Error"],"sourceRoot":"../../../src","sources":["utils/useAnimatedHeaderHeight.tsx"],"mappings":";;AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAG9B,OAAO,MAAMC,2BAA2B,gBAAGD,KAAK,CAACE,aAAa,CAE5DC,SAAS,CAAC;AAEZ,OAAO,SAASC,uBAAuBA,CAAA,EAAG;EACxC,MAAMC,aAAa,GAAGL,KAAK,CAACM,GAAG,CAACL,2BAA2B,CAAC;EAE5D,IAAII,aAAa,KAAKF,SAAS,EAAE;IAC/B,MAAM,IAAII,KAAK,CACb,uFACF,CAAC;EACH;EAEA,OAAOF,aAAa;AACtB","ignoreList":[]}
@@ -7,7 +7,7 @@ export function useInvalidPreventRemoveError(descriptors) {
7
7
  preventedRoutes
8
8
  } = usePreventRemoveContext();
9
9
  const preventedRouteKey = Object.keys(preventedRoutes)[0];
10
- const preventedDescriptor = descriptors[preventedRouteKey];
10
+ const preventedDescriptor = preventedRouteKey == null ? undefined : descriptors[preventedRouteKey];
11
11
  const isHeaderBackButtonMenuEnabledOnPreventedScreen = preventedDescriptor?.options?.headerBackButtonMenuEnabled;
12
12
  const preventedRouteName = preventedDescriptor?.route?.name;
13
13
  React.useEffect(() => {
@@ -1 +1 @@
1
- {"version":3,"names":["usePreventRemoveContext","React","useInvalidPreventRemoveError","descriptors","preventedRoutes","preventedRouteKey","Object","keys","preventedDescriptor","isHeaderBackButtonMenuEnabledOnPreventedScreen","options","headerBackButtonMenuEnabled","preventedRouteName","route","name","useEffect","message","console","error"],"sourceRoot":"../../../src","sources":["utils/useInvalidPreventRemoveError.tsx"],"mappings":";;AAAA,SAASA,uBAAuB,QAAQ,0BAA0B;AAClE,OAAO,KAAKC,KAAK,MAAM,OAAO;AAI9B,OAAO,SAASC,4BAA4BA,CAC1CC,WAAqC,EACrC;EACA,MAAM;IAAEC;EAAgB,CAAC,GAAGJ,uBAAuB,CAAC,CAAC;EACrD,MAAMK,iBAAiB,GAAGC,MAAM,CAACC,IAAI,CAACH,eAAe,CAAC,CAAC,CAAC,CAAC;EACzD,MAAMI,mBAAmB,GAAGL,WAAW,CAACE,iBAAiB,CAAC;EAC1D,MAAMI,8CAA8C,GAClDD,mBAAmB,EAAEE,OAAO,EAAEC,2BAA2B;EAC3D,MAAMC,kBAAkB,GAAGJ,mBAAmB,EAAEK,KAAK,EAAEC,IAAI;EAE3Db,KAAK,CAACc,SAAS,CAAC,MAAM;IACpB,IACEV,iBAAiB,IAAI,IAAI,IACzBI,8CAA8C,EAC9C;MACA,MAAMO,OAAO,GACX,cAAcJ,kBAAkB,2GAA2G,GAC3I,8DAA8DA,kBAAkB,mCAAmC;MACrHK,OAAO,CAACC,KAAK,CAACF,OAAO,CAAC;IACxB;EACF,CAAC,EAAE,CACDX,iBAAiB,EACjBI,8CAA8C,EAC9CG,kBAAkB,CACnB,CAAC;AACJ","ignoreList":[]}
1
+ {"version":3,"names":["usePreventRemoveContext","React","useInvalidPreventRemoveError","descriptors","preventedRoutes","preventedRouteKey","Object","keys","preventedDescriptor","undefined","isHeaderBackButtonMenuEnabledOnPreventedScreen","options","headerBackButtonMenuEnabled","preventedRouteName","route","name","useEffect","message","console","error"],"sourceRoot":"../../../src","sources":["utils/useInvalidPreventRemoveError.tsx"],"mappings":";;AAAA,SAASA,uBAAuB,QAAQ,0BAA0B;AAClE,OAAO,KAAKC,KAAK,MAAM,OAAO;AAI9B,OAAO,SAASC,4BAA4BA,CAC1CC,WAAqC,EACrC;EACA,MAAM;IAAEC;EAAgB,CAAC,GAAGJ,uBAAuB,CAAC,CAAC;EACrD,MAAMK,iBAAiB,GAAGC,MAAM,CAACC,IAAI,CAACH,eAAe,CAAC,CAAC,CAAC,CAAC;EACzD,MAAMI,mBAAmB,GACvBH,iBAAiB,IAAI,IAAI,GAAGI,SAAS,GAAGN,WAAW,CAACE,iBAAiB,CAAC;EACxE,MAAMK,8CAA8C,GAClDF,mBAAmB,EAAEG,OAAO,EAAEC,2BAA2B;EAC3D,MAAMC,kBAAkB,GAAGL,mBAAmB,EAAEM,KAAK,EAAEC,IAAI;EAE3Dd,KAAK,CAACe,SAAS,CAAC,MAAM;IACpB,IACEX,iBAAiB,IAAI,IAAI,IACzBK,8CAA8C,EAC9C;MACA,MAAMO,OAAO,GACX,cAAcJ,kBAAkB,2GAA2G,GAC3I,8DAA8DA,kBAAkB,mCAAmC;MACrHK,OAAO,CAACC,KAAK,CAACF,OAAO,CAAC;IACxB;EACF,CAAC,EAAE,CACDZ,iBAAiB,EACjBK,8CAA8C,EAC9CG,kBAAkB,CACnB,CAAC;AACJ","ignoreList":[]}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- import React from 'react';
3
+ import * as React from 'react';
4
4
  import { ScreenFooter } from 'react-native-screens';
5
5
  import { jsx as _jsx } from "react/jsx-runtime";
6
6
  export function FooterComponent({
@@ -1 +1 @@
1
- {"version":3,"names":["React","ScreenFooter","jsx","_jsx","FooterComponent","children","collapsable"],"sourceRoot":"../../../src","sources":["views/FooterComponent.tsx"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,YAAY,QAAQ,sBAAsB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAMpD,OAAO,SAASC,eAAeA,CAAC;EAAEC;AAAsB,CAAC,EAAE;EACzD,oBAAOF,IAAA,CAACF,YAAY;IAACK,WAAW,EAAE,KAAM;IAAAD,QAAA,EAAEA;EAAQ,CAAe,CAAC;AACpE","ignoreList":[]}
1
+ {"version":3,"names":["React","ScreenFooter","jsx","_jsx","FooterComponent","children","collapsable"],"sourceRoot":"../../../src","sources":["views/FooterComponent.tsx"],"mappings":";;AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,YAAY,QAAQ,sBAAsB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAMpD,OAAO,SAASC,eAAeA,CAAC;EAAEC;AAAsB,CAAC,EAAE;EACzD,oBAAOF,IAAA,CAACF,YAAY;IAACK,WAAW,EAAE,KAAM;IAAAD,QAAA,EAAEA;EAAQ,CAAe,CAAC;AACpE","ignoreList":[]}
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
 
3
3
  import { getHeaderTitle, Header, HeaderBackButton, HeaderBackContext, useHeaderHeight } from '@react-navigation/elements';
4
- import { SafeAreaProviderCompat, Screen } from '@react-navigation/elements/internal';
4
+ import { ActivityView, SafeAreaProviderCompat, Screen } from '@react-navigation/elements/internal';
5
5
  import { useLinkBuilder } from '@react-navigation/native';
6
6
  import * as React from 'react';
7
- import { Animated, Image, StyleSheet, View } from 'react-native';
7
+ import { Animated, StyleSheet, View } from 'react-native';
8
+ import { getModalRouteKeys } from "../utils/getModalRoutesKeys.js";
8
9
  import { AnimatedHeaderHeightContext } from "../utils/useAnimatedHeaderHeight.js";
9
10
  import { jsx as _jsx } from "react/jsx-runtime";
10
11
  const TRANSPARENT_PRESENTATIONS = ['transparentModal', 'containedTransparentModal'];
@@ -12,28 +13,35 @@ export function NativeStackView({
12
13
  state,
13
14
  descriptors
14
15
  }) {
15
- const parentHeaderBack = React.useContext(HeaderBackContext);
16
+ const parentHeaderBack = React.use(HeaderBackContext);
16
17
  const {
17
18
  buildHref
18
19
  } = useLinkBuilder();
20
+ const activeRoutes = state.routes.slice(0, state.index + 1);
21
+ const modalRouteKeys = getModalRouteKeys(activeRoutes, descriptors);
19
22
  return /*#__PURE__*/_jsx(SafeAreaProviderCompat, {
20
- children: state.routes.concat(state.preloadedRoutes).map((route, i) => {
23
+ children: state.routes.map((route, i) => {
21
24
  const isFocused = state.index === i;
22
- const previousKey = state.routes[i - 1]?.key;
23
- const nextKey = state.routes[i + 1]?.key;
25
+ const previousKey = activeRoutes[i - 1]?.key;
26
+ const nextKey = activeRoutes[i + 1]?.key;
24
27
  const previousDescriptor = previousKey ? descriptors[previousKey] : undefined;
25
28
  const nextDescriptor = nextKey ? descriptors[nextKey] : undefined;
29
+ const descriptor = descriptors[route.key];
30
+ if (descriptor == null) {
31
+ throw new Error(`Couldn't find a descriptor for route '${route.key}'.`);
32
+ }
26
33
  const {
27
34
  options,
28
35
  navigation,
29
36
  render
30
- } = descriptors[route.key];
37
+ } = descriptor;
31
38
  const headerBack = previousDescriptor ? {
32
39
  title: getHeaderTitle(previousDescriptor.options, previousDescriptor.route.name),
33
40
  href: buildHref(previousDescriptor.route.name, previousDescriptor.route.params)
34
41
  } : parentHeaderBack;
35
42
  const canGoBack = headerBack != null;
36
43
  const {
44
+ inactiveBehavior = 'pause',
37
45
  header,
38
46
  headerShown,
39
47
  headerBackIcon,
@@ -45,8 +53,20 @@ export function NativeStackView({
45
53
  ...rest
46
54
  } = options;
47
55
  const nextPresentation = nextDescriptor?.options.presentation;
48
- const isPreloaded = state.preloadedRoutes.some(r => r.key === route.key);
49
- return /*#__PURE__*/_jsx(Screen, {
56
+ const isNextScreenTransparent = nextPresentation != null && TRANSPARENT_PRESENTATIONS.includes(nextPresentation);
57
+ const isInactive = i > state.index;
58
+ const isBeforeLast = i === activeRoutes.length - 2;
59
+ const isNextScreenModal = nextKey ? modalRouteKeys.includes(nextKey) : false;
60
+ const activityMode =
61
+ // Render focused screens normally
62
+ isFocused ? 'normal' :
63
+ // Unpause preloaded and retained screens so updates are visible
64
+ // This lets effects on those screens run
65
+ inactiveBehavior === 'none' || isInactive || isNextScreenTransparent ? 'inert' : inactiveBehavior === 'unmount' && !isNextScreenModal && !isBeforeLast && !route.state ? 'unmounted' : 'paused';
66
+ if (activityMode === 'unmounted') {
67
+ return null;
68
+ }
69
+ const content = /*#__PURE__*/_jsx(Screen, {
50
70
  focused: isFocused,
51
71
  route: route,
52
72
  navigation: navigation,
@@ -75,21 +95,17 @@ export function NativeStackView({
75
95
  ...rest,
76
96
  label: headerBackTitle ?? label,
77
97
  tintColor: tintColor,
78
- backImage: headerBackIcon !== undefined ? () => /*#__PURE__*/_jsx(Image, {
79
- source: headerBackIcon.source,
80
- resizeMode: "contain",
81
- tintColor: tintColor,
82
- style: styles.backImage
83
- }) : undefined,
98
+ icon: headerBackIcon,
84
99
  onPress: navigation.goBack
85
100
  }) : headerLeft,
86
101
  headerTransparent: headerTransparent
87
102
  }),
88
- style: [StyleSheet.absoluteFill, {
89
- display: (isFocused || nextPresentation != null && TRANSPARENT_PRESENTATIONS.includes(nextPresentation)) && !isPreloaded ? 'flex' : 'none'
90
- }, presentation != null && TRANSPARENT_PRESENTATIONS.includes(presentation) ? {
91
- backgroundColor: 'transparent'
92
- } : null],
103
+ style: {
104
+ ...StyleSheet.absoluteFill,
105
+ ...(presentation != null && TRANSPARENT_PRESENTATIONS.includes(presentation) ? {
106
+ backgroundColor: 'transparent'
107
+ } : null)
108
+ },
93
109
  children: /*#__PURE__*/_jsx(HeaderBackContext.Provider, {
94
110
  value: headerBack,
95
111
  children: /*#__PURE__*/_jsx(AnimatedHeaderHeightProvider, {
@@ -100,6 +116,12 @@ export function NativeStackView({
100
116
  })
101
117
  })
102
118
  }, route.key);
119
+ return /*#__PURE__*/_jsx(ActivityView, {
120
+ mode: activityMode,
121
+ visible: isFocused || isNextScreenTransparent,
122
+ style: StyleSheet.absoluteFill,
123
+ children: content
124
+ }, route.key);
103
125
  })
104
126
  });
105
127
  }
@@ -119,11 +141,6 @@ const AnimatedHeaderHeightProvider = ({
119
141
  const styles = StyleSheet.create({
120
142
  contentContainer: {
121
143
  flex: 1
122
- },
123
- backImage: {
124
- height: 24,
125
- width: 24,
126
- margin: 3
127
144
  }
128
145
  });
129
146
  //# sourceMappingURL=NativeStackView.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["getHeaderTitle","Header","HeaderBackButton","HeaderBackContext","useHeaderHeight","SafeAreaProviderCompat","Screen","useLinkBuilder","React","Animated","Image","StyleSheet","View","AnimatedHeaderHeightContext","jsx","_jsx","TRANSPARENT_PRESENTATIONS","NativeStackView","state","descriptors","parentHeaderBack","useContext","buildHref","children","routes","concat","preloadedRoutes","map","route","i","isFocused","index","previousKey","key","nextKey","previousDescriptor","undefined","nextDescriptor","options","navigation","render","headerBack","title","name","href","params","canGoBack","header","headerShown","headerBackIcon","headerLeft","headerTransparent","headerBackTitle","presentation","contentStyle","rest","nextPresentation","isPreloaded","some","r","focused","back","label","tintColor","backImage","source","resizeMode","style","styles","onPress","goBack","absoluteFill","display","includes","backgroundColor","Provider","value","AnimatedHeaderHeightProvider","contentContainer","headerHeight","animatedHeaderHeight","useState","Value","useEffect","setValue","create","flex","height","width","margin"],"sourceRoot":"../../../src","sources":["views/NativeStackView.tsx"],"mappings":";;AAAA,SACEA,cAAc,EACdC,MAAM,EACNC,gBAAgB,EAChBC,iBAAiB,EACjBC,eAAe,QACV,4BAA4B;AACnC,SACEC,sBAAsB,EACtBC,MAAM,QACD,qCAAqC;AAC5C,SAGEC,cAAc,QACT,0BAA0B;AACjC,OAAO,KAAKC,KAAK,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AGA,CAAC;EACpCtD;AAGF,CAAC,KAAK;EACJ,MAAMwD,YAAY,GAAG3E,eAAe,CAAC,CAAC;EACtC,MAAM,CAAC4E,oBAAoB,CAAC,GAAGxE,KAAK,CAACyE,QAAQ,CAC3C,MAAM,IAAIxE,QAAQ,CAACyE,KAAK,CAACH,YAAY,CACvC,CAAC;EAEDvE,KAAK,CAAC2E,SAAS,CAAC,MAAM;IACpBH,oBAAoB,CAACI,QAAQ,CAACL,YAAY,CAAC;EAC7C,CAAC,EAAE,CAACC,oBAAoB,EAAED,YAAY,CAAC,CAAC;EAExC,oBACEhE,IAAA,CAACF,2BAA2B,CAAC8D,QAAQ;IAACC,KAAK,EAAEI,oBAAqB;IAAAzD,QAAA,EAC/DA;EAAQ,CAC2B,CAAC;AAE3C,CAAC;AAED,MAAM6C,MAAM,GAAGzD,UAAU,CAAC0E,MAAM,CAAC;EAC/BP,gBAAgB,EAAE;IAChBQ,IAAI,EAAE;EACR,CAAC;EACDtB,SAAS,EAAE;IACTuB,MAAM,EAAE,EAAE;IACVC,KAAK,EAAE,EAAE;IACTC,MAAM,EAAE;EACV;AACF,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["getHeaderTitle","Header","HeaderBackButton","HeaderBackContext","useHeaderHeight","ActivityView","SafeAreaProviderCompat","Screen","useLinkBuilder","React","Animated","StyleSheet","View","getModalRouteKeys","AnimatedHeaderHeightContext","jsx","_jsx","TRANSPARENT_PRESENTATIONS","NativeStackView","state","descriptors","parentHeaderBack","use","buildHref","activeRoutes","routes","slice","index","modalRouteKeys","children","map","route","i","isFocused","previousKey","key","nextKey","previousDescriptor","undefined","nextDescriptor","descriptor","Error","options","navigation","render","headerBack","title","name","href","params","canGoBack","inactiveBehavior","header","headerShown","headerBackIcon","headerLeft","headerTransparent","headerBackTitle","presentation","contentStyle","rest","nextPresentation","isNextScreenTransparent","includes","isInactive","isBeforeLast","length","isNextScreenModal","activityMode","content","focused","back","label","tintColor","icon","onPress","goBack","style","absoluteFill","backgroundColor","Provider","value","AnimatedHeaderHeightProvider","styles","contentContainer","mode","visible","headerHeight","animatedHeaderHeight","useState","Value","useEffect","setValue","create","flex"],"sourceRoot":"../../../src","sources":["views/NativeStackView.tsx"],"mappings":";;AAAA,SACEA,cAAc,EACdC,MAAM,EACNC,gBAAgB,EAChBC,iBAAiB,EACjBC,eAAe,QACV,4BAA4B;AACnC,SACEC,YAAY,EACZC,sBAAsB,EACtBC,MAAM,QACD,qCAAqC;AAC5C,SAGEC,cAAc,QACT,0BAA0B;AACjC,OAAO,KAAKC,KAAK,MAAM,OAAO;AAC9B,SAASC,QAAQ,EAAEC,UAAU,EAAEC,IAAI,QAAQ,cAAc;AAMzD,SAASC,iBAAiB,QAAQ,gCAA6B;AAC/D,SAASC,2BAA2B,QAAQ,qCAAkC;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAQ/E,MAAMC,yBAAyB,GAAG,CAChC,kBAAkB,EAClB,2BAA2B,CAC5B;AAED,OAAO,SAASC,eAAeA,CAAC;EAAEC,KAAK;EAAEC;AAAmB,CAAC,EAAE;EAC7D,MAAMC,gBAAgB,GAAGZ,KAAK,CAACa,GAAG,CAACnB,iBAAiB,CAAC;EACrD,MAAM;IAAEoB;EAAU,CAAC,GAAGf,cAAc,CAAC,CAAC;EAEtC,MAAMgB,YAAY,GAAGL,KAAK,CAACM,MAAM,CAACC,KAAK,CAAC,CAAC,EAAEP,KAAK,CAACQ,KAAK,GAAG,CAAC,CAAC;EAC3D,MAAMC,cAAc,GAAGf,iBAAiB,CAACW,YAAY,EAAEJ,WAAW,CAAC;EAEnE,oBACEJ,IAAA,CAACV,sBAAsB;IAAAuB,QAAA,EACpBV,KAAK,CAACM,MAAM,CAACK,GAAG,CAAC,CAACC,KAAK,EAAEC,CAAC,KAAK;MAC9B,MAAMC,SAAS,GAAGd,KAAK,CAACQ,KAAK,KAAKK,CAAC;MACnC,MAAME,WAAW,GAAGV,YAAY,CAACQ,CAAC,GAAG,CAAC,CAAC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C3C,MAAM,IAAI/E,QAAQ,CAACgF,KAAK,CAACH,YAAY,CACvC,CAAC;EAED9E,KAAK,CAACkF,SAAS,CAAC,MAAM;IACpBH,oBAAoB,CAACI,QAAQ,CAACL,YAAY,CAAC;EAC7C,CAAC,EAAE,CAACC,oBAAoB,EAAED,YAAY,CAAC,CAAC;EAExC,oBACEvE,IAAA,CAACF,2BAA2B,CAACkE,QAAQ;IAACC,KAAK,EAAEO,oBAAqB;IAAA3D,QAAA,EAC/DA;EAAQ,CAC2B,CAAC;AAE3C,CAAC;AAED,MAAMsD,MAAM,GAAGxE,UAAU,CAACkF,MAAM,CAAC;EAC/BT,gBAAgB,EAAE;IAChBU,IAAI,EAAE;EACR;AACF,CAAC,CAAC","ignoreList":[]}
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  import { getDefaultHeaderHeight, getHeaderTitle, HeaderBackContext, HeaderHeightContext, HeaderShownContext, useFrameSize } from '@react-navigation/elements';
4
- import { SafeAreaProviderCompat } from '@react-navigation/elements/internal';
4
+ import { ActivityView, SafeAreaProviderCompat } from '@react-navigation/elements/internal';
5
5
  import { NavigationProvider, StackActions, usePreventRemoveContext, useTheme } from '@react-navigation/native';
6
6
  import * as React from 'react';
7
7
  import { Animated, Platform, StyleSheet, useAnimatedValue, View } from 'react-native';
@@ -15,18 +15,20 @@ import { useInvalidPreventRemoveError } from "../utils/useInvalidPreventRemoveEr
15
15
  import { useHeaderConfigProps } from "./useHeaderConfigProps.js";
16
16
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
17
17
  const ANDROID_DEFAULT_HEADER_HEIGHT = 56;
18
- function isFabric() {
19
- return 'nativeFabricUIManager' in global;
20
- }
21
18
  const useNativeDriver = Platform.OS !== 'web';
19
+ const TRANSPARENT_PRESENTATIONS = ['transparentModal', 'containedTransparentModal'];
20
+ const SHEET_PRESENTATIONS = ['formSheet', 'pageSheet'];
22
21
  const SceneView = ({
23
22
  index,
24
23
  focused,
25
- shouldFreeze,
26
24
  descriptor,
27
25
  previousDescriptor,
28
26
  isPresentationModal,
29
- isPreloaded,
27
+ isNextScreenTransparent,
28
+ isNextScreenSheet,
29
+ isNextScreenModal,
30
+ isInactive,
31
+ isBeforeLast,
30
32
  onWillDisappear,
31
33
  onWillAppear,
32
34
  onAppear,
@@ -44,6 +46,7 @@ const SceneView = ({
44
46
  render
45
47
  } = descriptor;
46
48
  const {
49
+ inactiveBehavior = 'pause',
47
50
  animation,
48
51
  animationDuration,
49
52
  animationMatchesGesture,
@@ -76,7 +79,6 @@ const SceneView = ({
76
79
  statusBarStyle,
77
80
  unstable_sheetFooter,
78
81
  scrollEdgeEffects,
79
- freezeOnBlur,
80
82
  contentStyle
81
83
  } = options;
82
84
  let {
@@ -97,9 +99,9 @@ const SceneView = ({
97
99
 
98
100
  // Modals are fullscreen in landscape only on iPhone
99
101
  const isIPhone = Platform.OS === 'ios' && !(Platform.isPad || Platform.isTV);
100
- const isParentHeaderShown = React.useContext(HeaderShownContext);
101
- const parentHeaderHeight = React.useContext(HeaderHeightContext);
102
- const parentHeaderBack = React.useContext(HeaderBackContext);
102
+ const isParentHeaderShown = React.use(HeaderShownContext);
103
+ const parentHeaderHeight = React.use(HeaderHeightContext);
104
+ const parentHeaderBack = React.use(HeaderBackContext);
103
105
  const isLandscape = useFrameSize(frame => frame.width > frame.height);
104
106
  const topInset = isParentHeaderShown || Platform.OS === 'ios' && isModal || isIPhone && isLandscape ? 0 : insets.top;
105
107
  const defaultHeaderHeight = useFrameSize(frame => Platform.select({
@@ -148,6 +150,13 @@ const SceneView = ({
148
150
  headerTopInsetEnabled,
149
151
  headerBack
150
152
  });
153
+ const headerContainerRef = React.useRef(null);
154
+ React.useLayoutEffect(() => {
155
+ headerContainerRef.current?.measure((_x, _y, _width, height) => {
156
+ animatedHeaderHeight.setValue(height);
157
+ setHeaderHeight(height);
158
+ });
159
+ }, [animatedHeaderHeight]);
151
160
  const onHeaderHeightChange = hasCustomHeader ?
152
161
  // If we have a custom header, don't use native header height
153
162
  undefined :
@@ -171,7 +180,9 @@ const SceneView = ({
171
180
  if (doesHeaderAnimate) {
172
181
  setHeaderHeightDebounced(headerHeight);
173
182
  } else {
174
- if (Platform.OS === 'android' && headerHeight !== 0 && headerHeight <= ANDROID_DEFAULT_HEADER_HEIGHT) {
183
+ if (Platform.OS === 'android' && headerHeight !== 0 &&
184
+ // On some devices, height maybe slightly off (e.g. 56.17 instead of 56)
185
+ Math.round(headerHeight) <= ANDROID_DEFAULT_HEADER_HEIGHT) {
175
186
  // FIXME: On Android, events may get delivered out-of-order
176
187
  // https://github.com/facebook/react-native/issues/54636
177
188
  // We seem to get header height without status bar height first,
@@ -188,18 +199,77 @@ const SceneView = ({
188
199
  }
189
200
  }
190
201
  });
202
+ const activityMode =
203
+ // Render focused screens normally
204
+ // Unpause preloaded and retained screens so updates are visible
205
+ // Unpause previous screen so update isn't delayed for swipe back
206
+ // This lets effects on those screens run
207
+ // We don't need to handle inert as it'll be handled natively
208
+ inactiveBehavior === 'none' || focused || isInactive || isNextScreenTransparent ||
209
+ // Unpause the screen behind a sheet so it stays up to date
210
+ // Sheets don't cover the whole screen, so the screen behind is visible
211
+ isNextScreenSheet ||
212
+ // On iPadOS, the base screen is visible while modal is in a smaller area
213
+ // So also keep the screens unpaused
214
+ isNextScreenModal && !isModal || isBeforeLast ? 'normal' : inactiveBehavior === 'unmount' && !('state' in route && route.state) ? 'unmounted' : 'paused';
215
+ const content = /*#__PURE__*/_jsx(AnimatedHeaderHeightContext.Provider, {
216
+ value: animatedHeaderHeight,
217
+ children: /*#__PURE__*/_jsxs(HeaderHeightContext.Provider, {
218
+ value: headerShown !== false ? headerHeight : parentHeaderHeight ?? 0,
219
+ children: [headerBackground != null ?
220
+ /*#__PURE__*/
221
+ /**
222
+ * To show a custom header background, we render it at the top of the screen below the header
223
+ * The header also needs to be positioned absolutely (with `translucent` style)
224
+ */
225
+ _jsx(View, {
226
+ style: [styles.background, headerTransparent ? styles.translucent : null, {
227
+ height: headerHeight
228
+ }],
229
+ children: headerBackground()
230
+ }) : null, header != null && headerShown !== false ? /*#__PURE__*/_jsx(View, {
231
+ style: [styles.header, headerTransparent ? [styles.absolute,
232
+ // Specify an explicit min height for Android screen readers
233
+ {
234
+ minHeight: headerHeight
235
+ }] : null],
236
+ children: /*#__PURE__*/_jsx(View, {
237
+ ref: headerContainerRef,
238
+ onLayout: e => {
239
+ const headerHeight = e.nativeEvent.layout.height;
240
+ animatedHeaderHeight.setValue(headerHeight);
241
+ setHeaderHeight(headerHeight);
242
+ },
243
+ style: {
244
+ pointerEvents: 'box-none'
245
+ },
246
+ children: header({
247
+ back: headerBack,
248
+ options,
249
+ route,
250
+ navigation
251
+ })
252
+ })
253
+ }) : null, /*#__PURE__*/_jsx(HeaderShownContext.Provider, {
254
+ value: isParentHeaderShown || headerShown !== false,
255
+ children: /*#__PURE__*/_jsx(HeaderBackContext.Provider, {
256
+ value: headerBack,
257
+ children: render()
258
+ })
259
+ })]
260
+ })
261
+ });
191
262
  return /*#__PURE__*/_jsx(NavigationProvider, {
192
263
  navigation: navigation,
193
264
  route: route,
194
265
  children: /*#__PURE__*/_jsx(ScreenStackItem, {
195
266
  screenId: route.key,
196
- activityState: isPreloaded ? 0 : 2,
267
+ activityState: isInactive ? 0 : 2,
197
268
  style: StyleSheet.absoluteFill,
198
269
  "aria-hidden": !focused,
199
270
  customAnimationOnSwipe: animationMatchesGesture,
200
271
  fullScreenSwipeEnabled: fullScreenGestureEnabled,
201
272
  fullScreenSwipeShadowEnabled: fullScreenGestureShadowEnabled,
202
- freezeOnBlur: freezeOnBlur,
203
273
  gestureEnabled: Platform.OS === 'android' ?
204
274
  // This prop enables handling of system back gestures on Android
205
275
  // Since we handle them in JS side, we disable this
@@ -250,48 +320,16 @@ const SceneView = ({
250
320
  backgroundColor: colors.background
251
321
  }, contentStyle],
252
322
  headerConfig: headerConfig,
253
- unstable_sheetFooter: unstable_sheetFooter
254
- // When ts-expect-error is added, it affects all the props below it
255
- // So we keep any props that need it at the end
256
- // Otherwise invalid props may not be caught by TypeScript
257
- ,
258
- shouldFreeze: shouldFreeze,
259
- children: /*#__PURE__*/_jsx(AnimatedHeaderHeightContext.Provider, {
260
- value: animatedHeaderHeight,
261
- children: /*#__PURE__*/_jsxs(HeaderHeightContext.Provider, {
262
- value: headerShown !== false ? headerHeight : parentHeaderHeight ?? 0,
263
- children: [headerBackground != null ?
264
- /*#__PURE__*/
265
- /**
266
- * To show a custom header background, we render it at the top of the screen below the header
267
- * The header also needs to be positioned absolutely (with `translucent` style)
268
- */
269
- _jsx(View, {
270
- style: [styles.background, headerTransparent ? styles.translucent : null, {
271
- height: headerHeight
272
- }],
273
- children: headerBackground()
274
- }) : null, header != null && headerShown !== false ? /*#__PURE__*/_jsx(View, {
275
- onLayout: e => {
276
- const headerHeight = e.nativeEvent.layout.height;
277
- animatedHeaderHeight.setValue(headerHeight);
278
- setHeaderHeight(headerHeight);
279
- },
280
- style: [styles.header, headerTransparent ? styles.absolute : null],
281
- children: header({
282
- back: headerBack,
283
- options,
284
- route,
285
- navigation
286
- })
287
- }) : null, /*#__PURE__*/_jsx(HeaderShownContext.Provider, {
288
- value: isParentHeaderShown || headerShown !== false,
289
- children: /*#__PURE__*/_jsx(HeaderBackContext.Provider, {
290
- value: headerBack,
291
- children: render()
292
- })
293
- })]
294
- })
323
+ unstable_sheetFooter: unstable_sheetFooter,
324
+ children: activityMode === 'unmounted' ? null : /*#__PURE__*/_jsx(ActivityView, {
325
+ mode: activityMode,
326
+ visible:
327
+ // We don't need to hide the content since it's handled natively
328
+ // Hiding may also cause flash due to lag after native tab switch
329
+ // So we leave it always visible
330
+ true,
331
+ style: styles.content,
332
+ children: content
295
333
  })
296
334
  }, route.key)
297
335
  });
@@ -305,34 +343,38 @@ export function NativeStackView({
305
343
  setNextDismissedKey
306
344
  } = useDismissedRouteError(state);
307
345
  useInvalidPreventRemoveError(descriptors);
308
- const modalRouteKeys = getModalRouteKeys(state.routes, descriptors);
346
+ const activeRoutes = state.routes.slice(0, state.index + 1);
347
+ const modalRouteKeys = getModalRouteKeys(activeRoutes, descriptors);
309
348
  return /*#__PURE__*/_jsx(SafeAreaProviderCompat, {
310
349
  children: /*#__PURE__*/_jsx(ScreenStack, {
311
350
  style: styles.container,
312
- children: state.routes.concat(state.preloadedRoutes).map((route, index) => {
351
+ children: state.routes.map((route, index) => {
313
352
  const descriptor = descriptors[route.key];
353
+ if (descriptor == null) {
354
+ throw new Error(`Couldn't find a descriptor for route '${route.key}'.`);
355
+ }
314
356
  const isFocused = state.index === index;
315
- const isBelowFocused = state.index - 1 === index;
316
- const previousKey = state.routes[index - 1]?.key;
317
- const nextKey = state.routes[index + 1]?.key;
357
+ const previousKey = activeRoutes[index - 1]?.key;
358
+ const nextKey = activeRoutes[index + 1]?.key;
318
359
  const previousDescriptor = previousKey ? descriptors[previousKey] : undefined;
319
360
  const nextDescriptor = nextKey ? descriptors[nextKey] : undefined;
361
+ const nextPresentation = nextDescriptor?.options.presentation;
362
+ const isNextScreenTransparent = nextPresentation != null && TRANSPARENT_PRESENTATIONS.includes(nextPresentation);
363
+ const isNextScreenSheet = nextPresentation != null && SHEET_PRESENTATIONS.includes(nextPresentation);
364
+ const isNextScreenModal = nextKey ? modalRouteKeys.includes(nextKey) : false;
320
365
  const isModal = modalRouteKeys.includes(route.key);
321
- const isModalOnIos = isModal && Platform.OS === 'ios';
322
- const isPreloaded = state.preloadedRoutes.some(r => r.key === route.key);
323
-
324
- // On Fabric, when screen is frozen, animated and reanimated values are not updated
325
- // due to component being unmounted. To avoid this, we don't freeze the previous screen there
326
- const shouldFreeze = isFabric() ? !isPreloaded && !isFocused && !isBelowFocused && !isModalOnIos : !isPreloaded && !isFocused && !isModalOnIos;
327
366
  return /*#__PURE__*/_jsx(SceneView, {
328
367
  index: index,
329
368
  focused: isFocused,
330
- shouldFreeze: shouldFreeze,
331
369
  descriptor: descriptor,
332
370
  previousDescriptor: previousDescriptor,
333
371
  nextDescriptor: nextDescriptor,
334
372
  isPresentationModal: isModal,
335
- isPreloaded: isPreloaded,
373
+ isNextScreenTransparent: isNextScreenTransparent,
374
+ isNextScreenSheet: isNextScreenSheet,
375
+ isNextScreenModal: isNextScreenModal,
376
+ isInactive: index > state.index,
377
+ isBeforeLast: index === activeRoutes.length - 2,
336
378
  onWillDisappear: () => {
337
379
  navigation.emit({
338
380
  type: 'transitionStart',
@@ -416,6 +458,9 @@ const styles = StyleSheet.create({
416
458
  container: {
417
459
  flex: 1
418
460
  },
461
+ content: {
462
+ flex: 1
463
+ },
419
464
  header: {
420
465
  zIndex: 1
421
466
  },