| ... | @@ -1,8 +1,39 @@ | ... | @@ -1,8 +1,39 @@ |
| 1 | diff --git a/lib/module/views/NativeStackView.native.js b/lib/module/views/NativeStackView.native.js | 1 | diff --git a/lib/module/views/NativeStackView.native.js b/lib/module/views/NativeStackView.native.js |
| 2 | index c342e90bffde9ad5044b6167bdde2e19be219270..5d3e4407aa1bb68b873cf164adf5a9f0b487bb0b 100644 | 2 | index c342e90bffde9ad5044b6167bdde2e19be219270..4a045490f0650b4a0c821b3e799cf3d18531417f 100644 |
| 3 | --- a/lib/module/views/NativeStackView.native.js | 3 | --- a/lib/module/views/NativeStackView.native.js |
| 4 | +++ b/lib/module/views/NativeStackView.native.js | 4 | +++ b/lib/module/views/NativeStackView.native.js |
| 5 | @@ -370,6 +370,17 @@ export function NativeStackView({ | 5 | @@ -17,8 +17,12 @@ const ANDROID_DEFAULT_HEADER_HEIGHT = 56; |
| | 6 | function isFabric() { |
| | 7 | return 'nativeFabricUIManager' in global; |
| | 8 | } |
| | 9 | +function SceneNavigationProvider({ presentationEnvelope, ...props }) { |
| | 10 | + return presentationEnvelope ? props.children : /*#__PURE__*/_jsx(NavigationProvider, props); |
| | 11 | +} |
| | 12 | const useNativeDriver = Platform.OS !== 'web'; |
| | 13 | const SceneView = ({ |
| | 14 | + presentationEnvelope, |
| | 15 | index, |
| | 16 | focused, |
| | 17 | shouldFreeze, |
| | 18 | @@ -231,7 +235,8 @@ const SceneView = ({ |
| | 19 | } |
| | 20 | } |
| | 21 | }); |
| | 22 | - return /*#__PURE__*/_jsx(NavigationProvider, { |
| | 23 | + return /*#__PURE__*/_jsx(SceneNavigationProvider, { |
| | 24 | + presentationEnvelope, |
| | 25 | route: route, |
| | 26 | navigation: navigation, |
| | 27 | children: /*#__PURE__*/_jsx(ScreenStackItem, { |
| | 28 | @@ -353,6 +358,7 @@ const SceneView = ({ |
| | 29 | }); |
| | 30 | }; |
| | 31 | export function NativeStackView({ |
| | 32 | + presentationEnvelope, |
| | 33 | state, |
| | 34 | navigation, |
| | 35 | descriptors, |
| | 36 | @@ -370,6 +376,17 @@ export function NativeStackView({ |
| 6 | return /*#__PURE__*/_jsx(SafeAreaProviderCompat, { | 37 | return /*#__PURE__*/_jsx(SafeAreaProviderCompat, { |
| 7 | children: /*#__PURE__*/_jsx(ScreenStack, { | 38 | children: /*#__PURE__*/_jsx(ScreenStack, { |
| 8 | style: styles.container, | 39 | style: styles.container, |
| ... | @@ -20,6 +51,14 @@ index c342e90bffde9ad5044b6167bdde2e19be219270..5d3e4407aa1bb68b873cf164adf5a9f0 | ... | @@ -20,6 +51,14 @@ index c342e90bffde9ad5044b6167bdde2e19be219270..5d3e4407aa1bb68b873cf164adf5a9f0 |
| 20 | children: state.routes.concat(state.preloadedRoutes).map((route, index) => { | 51 | children: state.routes.concat(state.preloadedRoutes).map((route, index) => { |
| 21 | const descriptor = descriptors[route.key] ?? preloadedDescriptors[route.key]; | 52 | const descriptor = descriptors[route.key] ?? preloadedDescriptors[route.key]; |
| 22 | const isFocused = state.index === index; | 53 | const isFocused = state.index === index; |
| | 54 | @@ -386,6 +403,7 @@ export function NativeStackView({ |
| | 55 | // due to component being unmounted. To avoid this, we don't freeze the previous screen there |
| | 56 | const shouldFreeze = isFabric() ? !isPreloaded && !isFocused && !isBelowFocused && !isModalOnIos : !isPreloaded && !isFocused && !isModalOnIos; |
| | 57 | return /*#__PURE__*/_jsx(SceneView, { |
| | 58 | + presentationEnvelope, |
| | 59 | index: index, |
| | 60 | focused: isFocused, |
| | 61 | shouldFreeze: shouldFreeze, |
| 23 | diff --git a/lib/module/views/useHeaderConfigProps.js b/lib/module/views/useHeaderConfigProps.js | 62 | diff --git a/lib/module/views/useHeaderConfigProps.js b/lib/module/views/useHeaderConfigProps.js |
| 24 | index 9c21aa48cb580704aa17e59d9cdadcc612a1e4ff..a1b3a38368c5ef2257570f382e87df5d6f55b11e 100644 | 63 | index 9c21aa48cb580704aa17e59d9cdadcc612a1e4ff..a1b3a38368c5ef2257570f382e87df5d6f55b11e 100644 |
| 25 | --- a/lib/module/views/useHeaderConfigProps.js | 64 | --- a/lib/module/views/useHeaderConfigProps.js |
| ... | @@ -189,3 +228,110 @@ index 3f3fff405048b3c2250afbe99dd7f35cecb9a6d5..bb062b898cfa77f8c02f951dc9d81b51 | ... | @@ -189,3 +228,110 @@ index 3f3fff405048b3c2250afbe99dd7f35cecb9a6d5..bb062b898cfa77f8c02f951dc9d81b51 |
| 189 | > | 228 | > |
| 190 | {item.element} | 229 | {item.element} |
| 191 | </ScreenStackHeaderRightView> | 230 | </ScreenStackHeaderRightView> |
| | 231 | diff --git a/lib/typescript/src/views/NativeStackView.native.d.ts b/lib/typescript/src/views/NativeStackView.native.d.ts |
| | 232 | index c0d37db3b4a2a4e9340c76333821f44a87cd624b..eb3db8f511799b335a17edea31a2acd17627f909 100644 |
| | 233 | --- a/lib/typescript/src/views/NativeStackView.native.d.ts |
| | 234 | +++ b/lib/typescript/src/views/NativeStackView.native.d.ts |
| | 235 | @@ -1,11 +1,12 @@ |
| | 236 | import { type ParamListBase, type RouteProp, type StackNavigationState } from '@react-navigation/native'; |
| | 237 | import type { NativeStackDescriptor, NativeStackDescriptorMap, NativeStackNavigationHelpers } from '../types.js'; |
| | 238 | type Props = { |
| | 239 | + presentationEnvelope?: boolean; |
| | 240 | state: StackNavigationState<ParamListBase>; |
| | 241 | navigation: NativeStackNavigationHelpers; |
| | 242 | descriptors: NativeStackDescriptorMap; |
| | 243 | describe: (route: RouteProp<ParamListBase>, placeholder: boolean) => NativeStackDescriptor; |
| | 244 | }; |
| | 245 | -export declare function NativeStackView({ state, navigation, descriptors, describe, }: Props): import("react/jsx-runtime").JSX.Element; |
| | 246 | +export declare function NativeStackView({ presentationEnvelope, state, navigation, descriptors, describe, }: Props): import("react/jsx-runtime").JSX.Element; |
| | 247 | export {}; |
| | 248 | //# sourceMappingURL=NativeStackView.native.d.ts.map |
| | 249 | \ No newline at end of file |
| | 250 | diff --git a/src/views/NativeStackView.native.tsx b/src/views/NativeStackView.native.tsx |
| | 251 | index 416cd90057cea362371a4308dd9985b086c5ccaa..7188a3daf0af2004303b21f89d3c0c7073517ef8 100644 |
| | 252 | --- a/src/views/NativeStackView.native.tsx |
| | 253 | +++ b/src/views/NativeStackView.native.tsx |
| | 254 | @@ -51,7 +51,14 @@ function isFabric() { |
| | 255 | return 'nativeFabricUIManager' in global; |
| | 256 | } |
| | 257 | |
| | 258 | +// A presentation envelope contains descriptors from its owning navigator. |
| | 259 | +// Its synthetic route must not override those descriptors' focus state. |
| | 260 | +function SceneNavigationProvider({ presentationEnvelope, ...props }: React.ComponentProps<typeof NavigationProvider> & { presentationEnvelope?: boolean }) { |
| | 261 | + return presentationEnvelope ? props.children : <NavigationProvider {...props} />; |
| | 262 | +} |
| | 263 | + |
| | 264 | type SceneViewProps = { |
| | 265 | + presentationEnvelope?: boolean; |
| | 266 | index: number; |
| | 267 | focused: boolean; |
| | 268 | shouldFreeze: boolean; |
| | 269 | @@ -74,6 +81,7 @@ type SceneViewProps = { |
| | 270 | const useNativeDriver = Platform.OS !== 'web'; |
| | 271 | |
| | 272 | const SceneView = ({ |
| | 273 | + presentationEnvelope, |
| | 274 | index, |
| | 275 | focused, |
| | 276 | shouldFreeze, |
| | 277 | @@ -356,7 +364,7 @@ const SceneView = ({ |
| | 278 | ); |
| | 279 | |
| | 280 | return ( |
| | 281 | - <NavigationProvider route={route} navigation={navigation}> |
| | 282 | + <SceneNavigationProvider presentationEnvelope={presentationEnvelope} route={route} navigation={navigation}> |
| | 283 | <ScreenStackItem |
| | 284 | screenId={route.key} |
| | 285 | activityState={isPreloaded ? 0 : 2} |
| | 286 | @@ -493,11 +501,12 @@ const SceneView = ({ |
| | 287 | </HeaderHeightContext.Provider> |
| | 288 | </AnimatedHeaderHeightContext.Provider> |
| | 289 | </ScreenStackItem> |
| | 290 | - </NavigationProvider> |
| | 291 | + </SceneNavigationProvider> |
| | 292 | ); |
| | 293 | }; |
| | 294 | |
| | 295 | type Props = { |
| | 296 | + presentationEnvelope?: boolean; |
| | 297 | state: StackNavigationState<ParamListBase>; |
| | 298 | navigation: NativeStackNavigationHelpers; |
| | 299 | descriptors: NativeStackDescriptorMap; |
| | 300 | @@ -508,6 +517,7 @@ type Props = { |
| | 301 | }; |
| | 302 | |
| | 303 | export function NativeStackView({ |
| | 304 | + presentationEnvelope, |
| | 305 | state, |
| | 306 | navigation, |
| | 307 | descriptors, |
| | 308 | @@ -555,6 +565,7 @@ export function NativeStackView({ |
| | 309 | |
| | 310 | return ( |
| | 311 | <SceneView |
| | 312 | + presentationEnvelope={presentationEnvelope} |
| | 313 | key={route.key} |
| | 314 | index={index} |
| | 315 | focused={isFocused} |
| | 316 | diff --git a/lib/typescript/src/views/NativeStackView.d.ts b/lib/typescript/src/views/NativeStackView.d.ts |
| | 317 | --- a/lib/typescript/src/views/NativeStackView.d.ts |
| | 318 | +++ b/lib/typescript/src/views/NativeStackView.d.ts |
| | 319 | @@ -1,6 +1,7 @@ |
| | 320 | import { type ParamListBase, type RouteProp, type StackNavigationState } from '@react-navigation/native'; |
| | 321 | import type { NativeStackDescriptor, NativeStackDescriptorMap, NativeStackNavigationHelpers } from '../types.js'; |
| | 322 | type Props = { |
| | 323 | + presentationEnvelope?: boolean; |
| | 324 | state: StackNavigationState<ParamListBase>; |
| | 325 | navigation: NativeStackNavigationHelpers; |
| | 326 | descriptors: NativeStackDescriptorMap; |
| | 327 | diff --git a/src/views/NativeStackView.tsx b/src/views/NativeStackView.tsx |
| | 328 | --- a/src/views/NativeStackView.tsx |
| | 329 | +++ b/src/views/NativeStackView.tsx |
| | 330 | @@ -24,6 +24,7 @@ |
| | 331 | import { AnimatedHeaderHeightContext } from '../utils/useAnimatedHeaderHeight'; |
| | 332 | |
| | 333 | type Props = { |
| | 334 | + presentationEnvelope?: boolean; |
| | 335 | state: StackNavigationState<ParamListBase>; |
| | 336 | // This is used for the native implementation of the stack. |
| | 337 | navigation: NativeStackNavigationHelpers; |